mysql: Replacing column value with values from column from another table -


i have 2 datasets, , b. in both datasets, have column called "campaign" named differently. example, in a, campaign referred 'cde-332 blabla' , in b, same campaign referred 'fgi-332 bleh bleh'. campaign might 'cde-345 blabla' in , 'fgi-345 bleh bleh' in b. basically, 3 digits in each dataset connect rows.

my question becomes: there way mysql replace in campaigns seen in b, have matching 3 digits? thanks!

join 2 tables using substr() join condition, , update table a.

update tablea join tableb b  on substr(a.campaign, locate(a.campaign, '-')+1, 3) = substr(b.campaign, locate(b.campaign, '-')+1, 3) set a.campaign = b.campaign 

Comments