| Welcome to WebmasterWorld Guest from 22.214.171.124 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|Urgent help Find Replace Query |
Urgent help Find Replace Query
| 11:40 am on Jun 21, 2010 (gmt 0)|
Have use find and replace simple query before but for this need help
Table name - TM
field 1= title
field 2= cat
field 3= subcat
Want to find and replace all entries with subcat = 13 to 14 where field 1 title has keyword faucet and where field 2 cat = 18
| 4:17 pm on Jun 21, 2010 (gmt 0)|
SQL/mySQL is very intuitive, you almost have it right here. :-)
|Want to find and replace all entries with subcat = 13 to 14 where field 1 title has keyword faucet and where field 2 cat = 18 |
So try this.
update TM set subcat=14 where subcat=13 and cat = 18 and title like '%faucet%';
Before you do that, make sure it's correct, print out the results with this
select id, subcat, cat from TM where subcat=13 and cat = 18 and title like '%faucet%';
then print "would update id $id, subcat $subcat, cat $cat<br>\n";
A note on like: this will match faucet *anywhere* in title
fix faucet drip
if the title is *exactly* faucet, use this instead.
update TM set subcat=14 where subcat=13 and cat = 18 and title = 'faucet';
It will be faster.
Let me guess, moving a database with joined tables using auto increment, now the auto increments don't join properly?
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved