Pages

Wednesday, November 9, 2011

Mysql update table comparing with another table

update `fjm_listings` a, fjm_zipcodes b set a.search_title = if(b.zipcode_abbr = '',  CONCAT(trim(replace(replace(a.title, a.class_name, ''), '<br>', '')),'<br>', a.class_name,  ' ', b.state_abbr),
CONCAT(trim(replace(replace(a.title, a.class_name, ''), '<br>', '')), '<br>', a.class_name, ' ', b.zipcode_abbr, ' ', b.state_abbr)) where a.zipcode = b.zipcode

No comments:

Post a Comment