Search and replace in MySQL
July 19, 2007 2:17 PM   Subscribe

MySQL: How do I search and replace a value in a table under certain conditions:

Record belongs to tables "pages_language_overlay" or "tt_content", need to change the value "sys_language_uid" from 2 to 3 (only when it's == 2 in the first place).
This is for a LAMP + Typo3-based website, and I can do this via phpmyadmin or PuTTY.
posted by signal to Computers & Internet (5 answers total) 1 user marked this as a favorite
 
This should help
posted by sanko at 2:26 PM on July 19, 2007


I'm in a generous mood... (off the top of my head, hopefully there's no obvious mistakes)

UPDATE pages_language_overlay SET sys_language_uid='3' WHERE sys_language_uid='2';
UPDATE tt_content SET sys_language_uid='3' WHERE sys_language_uid='2';
posted by cgg at 2:32 PM on July 19, 2007


You also might be interested in case statements.
posted by Pants! at 2:41 PM on July 19, 2007


This seems so simple that I'm inclined to read more into it. What does Record belongs to tables "pages_language_overlay" or "tt_content" mean? "Or"?
posted by cmiller at 2:44 PM on July 19, 2007


cmiller: no, it is so simple.
You're all winners in my book, but cgg went the extra 1.6 Km, so...
posted by signal at 2:49 PM on July 19, 2007


« Older Why is the US so desirous of independence for...   |   Is there life after 'I Now Pronounce You Chuck and... Newer »
This thread is closed to new comments.