SQLTeam.com | Weblogs | Forums

Ho do I populate with lookup value?


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

SELECT c.email,
	TableC c
	INNER JOIN CountryCodeValues lk
		ON lk.countrycode = c.countrycode;


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


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)