I have a MySQL
database table that contains a column named Country
. Sometimes it's a full CNT
name, sometimes ISO 3
or ISO 2
. CNT code is depending on the source file used for this table. The country names are always written in uppercase (CANADA, POLAND etc.).
I need to add some statement into my query what would convert the country name
or country ISO 3
code to the ISO 2
CNT code - (CA, PL etc.).
I tried to use an easy solution:
select left (Country, 2) from tb_name
This is not useful for all countries. If I will take only the first two left letters from 'POLAND' then I will get 'PO' instead of 'PL'.
I will really appreciate any advice from you.