Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Initially, this is what we can see when I run SELECT * FROM block_custom;:

| bid | body             | info   | format    |
|   1 | Block1 body here | Block1 | full_html |
|   2 | Block2 body here | Block2 | full_html |
|   3 | Block3 body here | Block3 | full_html |

In order to replace info and bodyof table block_custom, I'm using below query:

update block_custom set info = replace(info,'Block2','Block2new');
update block_custom set body = replace(body,'body here','newbody here');

This is explanation of my query:

update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');

When running this query to change body, it will replace in all row of column body.

How to make it change only in row 2 (bid 2)?

share|improve this question
up vote 0 down vote accepted

As always, restrict it with a WHERE clause.

... WHERE bid=2
share|improve this answer
But how to use the WHERE bid=3 in one line? (All example I found using clause is not one line) – Roberto Apasajja Mar 5 '12 at 4:08
I got it, thanks – Roberto Apasajja Mar 5 '12 at 4:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.