Solved

How to join on two disparate keys (one is string, other is int)?

Posted on 2009-07-16
3
314 Views
Last Modified: 2012-08-14
I have two tables in MS Access that are suppose to share a common key...however the number in one is actually stored as a string while the other is stored as an int.

I think I want to use the convert() function...

Select blah1.key, blah2.key
from blah1
INNER JOIN
blah2
ON blah1.key = blah2.key

How do I use the convert() or something like it for the join?
0
Comment
Question by:M3hcSS
3 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 24873399
Either use CInt(strColumnName) or CStr(intColumnName).
Select blah1.key, blah2.key

from blah1

INNER JOIN

blah2

ON blah1.key = CStr(blah2.key)
 

--OR--
 

Select blah1.key, blah2.key

from blah1

INNER JOIN

blah2

ON CInt(blah1.key) = blah2.key

Open in new window

0
 
LVL 30

Expert Comment

by:hnasr
ID: 24874244
You may need to create a query of any table changing the format of the relevant field.
Then join the query with the other table.
0
 
LVL 2

Accepted Solution

by:
M3hcSS earned 0 total points
ID: 24938603
Solution was

JOIN Table2 ON Table2.CityList LIKE '%' + Table1.City + '%'
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now