Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL replacing one value with another

Tags:

sql

I have a table known as address_book and I wish to change a value of column "entry_country_id" from 257 to 222. Bear in mind I have other values in this row, but I just want 257 (the value in column entry_country_id) changed to 222.

like image 371
user1957689 Avatar asked Jan 08 '13 10:01

user1957689


2 Answers

UPDATE address_book
SET entry_country_id = 222
WHERE entry_country_id = 257

OR

UPDATE address_book
SET entry_country_id = '222'
WHERE entry_country_id = '257'

if the column contains strings

like image 137
twoleggedhorse Avatar answered Oct 05 '22 12:10

twoleggedhorse


Update address_book
set entry_country_id=222
where entry_country_id=257
like image 30
Madhivanan Avatar answered Oct 05 '22 13:10

Madhivanan