homepage Welcome to WebmasterWorld Guest from
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

Replace text
Replace text in multiple rows

Msg#: 4416849 posted 11:16 pm on Feb 12, 2012 (gmt 0)

Well hello,

I know you may replace text from a sql table by using something like the fallowing:

UPDATE phpbb_posts SET post_text = replace(post_text, 'Î', '');

But would there be a way to replace something from two rows at once?

Something ilke this:

UPDATE phpbb_posts SET post_text, post_subject = replace(post_text, post_subject, 'ă', ';');

I know there could be just a second update line of code that does that separtely, but can you do it from just one line?

Like you do for example:

UPDATE phpbb_topics SET topic_time = '1329086612',topic_views = '0' WHERE topic_id =747 ;

Thanks in advance.



WebmasterWorld Senior Member 5+ Year Member

Msg#: 4416849 posted 10:58 pm on Mar 8, 2012 (gmt 0)

Yes, you can set multiple columns at a time and accross multiple rows
UPDATE phpbb_posts
SET post_text = replace(post_text, 'ă', ';'),
post_subject = replace(post_subject, 'ă', ';')
WHERE ...;


Msg#: 4416849 posted 12:22 am on May 5, 2012 (gmt 0)

Thanks mate. I dont need it anymore as i just wanted to help a forum owner that has messed up his db.

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