on-internet
← Community

MySQL update fields based on value in another field

Stack Overflow ·

I need to update a field based on the presence of a string in another field. I need to do this for hundreds of search strings. This is what I have thus far: SET SQL_SAFE_UPDATES=0; UPDATE business_table SET `chain` = '7-Eleven' WHERE business_name LIKE BINARY '%7-Eleven%' OR business_name LIKE BINARY '%7 Eleven%'; UPDATE business_table SET `chain` = 'A&W' WHERE business_name LIKE '%A & W%' OR business_name LIKE '%A&W%'; UPDATE business_table SET `chain` = 'Blenz Coffee' WHERE business_name LIKE BINARY '%Blenz Coffee%'; UPDATE business_table SET `chain` = 'Booster Juice' WHERE business_name LIK

Comments

Sign in or sign up to comment and upvote.

No comments yet.