Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 383
  • Last Modified:

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?
0
M3hcSS
Asked:
M3hcSS
1 Solution
 
käµfm³d 👽Commented:
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
 
hnasrCommented:
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
 
M3hcSSAuthor Commented:
Solution was

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now