Welcome to WebmasterWorld Guest from 54.211.96.99

Forum Moderators: open

Message Too Old, No Replies

Replace text

Replace text in multiple rows

   
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.
10:58 pm on Mar 8, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



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 ...;
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.