Welcome to WebmasterWorld Guest from 54.227.110.209

Forum Moderators: open

Message Too Old, No Replies

Urgent help Find Replace Query

Urgent help Find Replace Query

     

rajivadhy

11:40 am on Jun 21, 2010 (gmt 0)

5+ Year Member



HI,
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

Please help

rocknbil

4:17 pm on Jun 21, 2010 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

shiny faucets
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?
 

Featured Threads

Hot Threads This Week

Hot Threads This Month