Onur Aydın
Onur Aydın

Reputation: 13

Which SQL command should I use to replace specific values?

I have numeric values like below:

0
2323
1003

I have to replace only single zeros to 100. I tried the following code but it affects the other values which include 0.

UPDATE table_name SET field_name= replace(field_name,"0","100");

The values should be like below after the transaction:

100
2323
1003

Which SQL command should I use?

Thanks.

Upvotes: 0

Views: 38

Answers (1)

Vamsi Prabhala
Vamsi Prabhala

Reputation: 49260

You should use a where clause instead of replace.

UPDATE table_name SET field_name = 100
where field_name = 0

Upvotes: 1

Related Questions