Link to home
Start Free TrialLog in
Avatar of M3hcSS
M3hcSS

asked on

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

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?
Avatar of kaufmed
kaufmed
Flag of United States of America image

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

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.
ASKER CERTIFIED SOLUTION
Avatar of M3hcSS
M3hcSS

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial