update lbmoverseascountry a inner join lbmcodeitems b on a.CountryName like CONCAT(b.name,'%') set CountryCode=b.`Code` where b.setid='A019' and Length(a.CountryCode)>=6 select a.CountryName,b.code from lbmoverseascountry a left join lbmcodeitems b on a.CountryName=b.name where setid='A019' order by b.code select a.CountryName,b.code ,b.`NAME` from lbmoverseascountry a left join lbmcodeitems b on a.CountryName like CONCAT('%', b.name ,'%') where Length(a.CountryCode)>=6 select a.CountryName,b.code ,b.`NAME` from lbmoverseascountry a left join lbmcodeitems b on b.name like CONCAT('%',a.CountryName,'%') where Length(a.CountryCode)>=6