Both feilds are VARCHAR but geoname.country + '.' + geoname.admin1 returns 0
Main Topics
Browse All TopicsI'm trying to make a LEFT join using SQL. However the fields I am trying to join are not exactly the same. I have two tables 'geonams' and 'admin1codes' the key in 'admin1codes' is like this 'FR.01' and the 'geoname' table contains two columns that make up this key so there is a 'geoname.country' that is 'FR' and an 'admin1' that is '01'.
My question is how can i combine these two columns to test for a match in the other table, my attempt was:
LEFT JOIN admin1codes ON admin1codes.code = geoname.country + '.' + geoname.admin1
But that didn't work, how do i do this?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
>i should of mentioned in the question it was MySQL.
actually, you HAD. via the zone selection... I just had not put my glasses on..
now, to "explain" what happens in mysql when you use +: is makes the "maths", and not string concatenation.
and implicitly converting anything that is not numerically to 0 ... so <string> + '.' + <string> is evaluated to 0 + 0 + 0
glad I could help
Business Accounts
Answer for Membership
by: angelIIIPosted on 2009-08-12 at 12:18:21ID: 25081861
the code you showed is correct.
however, if any of the fields is CHAR instead of VARCHAR, this might explain things...