have 2 tables one countryCapCurLang another CountryBasicInfo both have common Varchar(130) Null column COUNTRY_NAME. which include country names. both have alpha_2 columns with values in CountryBasicInfo like AF for Afghanistan etc.i wish to add alpha_2 values to countryCapCurLang table table countryCapCurLang :
| id | alpha_2 |COUNTRY_NAME|
| -- | ------- | ---------- |
| 1 | Null |Afghanistan |
| 2 | Null |France |
and table CountryBasicInfo :
| id | alpha_2 |COUNTRY_NAME|
| -- | ------- | ---------- |
| 1 | AF |Afghanistan |
| 2 | FR |France |
updated using
update countryCapCurLang
left join CountryBasicInfo using(COUNTRY_NAME)
set countryCapCurLang.alpha_2=(select * from CountryBasicInfo where countryCapCurLang.Country_NAME like '%'+CountryBasicInfo.COUNTRY_NAME+'%');
which gave errors on afghanistan, russia etc and did zero updation. if i donot use like and simply put = sign, it updates many but leaves 24 out of 195 countries.
select * from CountryBasicInfo where country_name='Afghanistan'
it gave no result then
select *
from CountryBasicInfo
where country_name like '%'+Afghanistan'+'%'
gave a row. i thought its due to some space etc in entry. hence tried a lot of few are under.
UPDATE `countrylangcapcur`
SET `countrylangcapcur`.`alpha_2`=( select `alpha_2` from `countrybasicinfo` LEFT JOIN countrylangcapcur ON `countrylangcapcur`.`COUNTRY_NAME` like '%'+`countrybasicinfo`.`COUNTRY_NAME`+'%');
` then i tried
update `countrylangcapcur`
INNER JOIN `countrybasicinfo` on `countrylangcapcur`.`country_name` like '%'+`countrybasicinfo`.`country_name`+'%'
SET `countrylangcapcur`.`alpha_2`=( select `alpha_2` from `countrybasicinfo` WHERE `countrylangcapcur`.`country_name` like '%'+`countrybasicinfo`.`country_name`+'%');`