mysql关联更新like,CONCAT,Length 函数使用

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
原文地址:https://www.cnblogs.com/liuyudong0825/p/15337212.html