I need to search for countries ids and I ran into a problem, for example, let's take the country "Bolivia".
The Country table has a "CountryName" and "Alternative Names"
For the example of "Bolivia".
IdCountry Name Code AlternateNames
---------- -------------------------------- ----- ---------------------------
29 Bolivia, Plurinational State Of BO Bolivia, Bolivien, Bolivie
This is the query I've created:
SELECT cou.CountryID
FROM Doppler2011.dbo.Country cou
WHERE (cou.AlternateNames IS NOT NULL AND 'Bolivia' like '%'+cou.AlternateNames+'%')
OR 'Bolivia' like cou.Name
As you see, I need the cou.AlternateNames
in the Right side of the like to match the name of the country with some of the alternatives names, for the countries which the name is the same as the cou.Name
, the query works, but the problem is with those that have to match with AlternateNames
Can anyone help me?
Thanks!