homepage Welcome to WebmasterWorld Guest from 54.166.255.168
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
Urgent help Find Replace Query
Urgent help Find Replace Query
rajivadhy

5+ Year Member



 
Msg#: 4155953 posted 11:40 am on Jun 21, 2010 (gmt 0)

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

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



 
Msg#: 4155953 posted 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

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?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved