Solved

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

Posted on 2009-07-16
3
345 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 75

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

856 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