SQLTeam.com | Weblogs | Forums

Ho do I populate with lookup value?


#1

I need to do a simple select of email and country but the country has to be the output of a lookup table that cleans up country values in our data. I'm not sure how to code the lookup piece (between asterixs below)

select c.email,
*** Lookup c.country IN CountryCodeValues retrieve lk.country ***
as country
FROM
TABLE c


#2
SELECT c.email,
	lk.country
FROM
	TableC c
	INNER JOIN CountryCodeValues lk
		ON lk.countrycode = c.countrycode;

#3

It works. Thank you. I had tried it as a Left Join before and that didn't work. But Inner Join works.


#4

LEFT JOIN should have worked too. If you use LEFT JOIN, you will get records from TableC even if there is no countrycode (which is probably what you want)