senthil
senthil

Reputation:

Update multiple rows

How to update multiple rows using id as primary key in a table with a single query ??

i have collection of id's say 23,25,26 . i have to update todo_deleted column as checked for all the three rows with ids 23,25,26

I need a query which should be very efficient.. Post ans if u know.. Thanx in advance

Upvotes: 4

Views: 844

Answers (2)

IordanTanev
IordanTanev

Reputation: 6240

UPDATE TABLE
SET COLUMN = NEW VALUE
WHERE ID IN ( 23, 25 ,26 )

Upvotes: 4

nickf
nickf

Reputation: 546005

Like this, using IN:

 UPDATE `myTable` SET `todo_deleted` = 1 WHERE `id` IN (23, 25, 26)

Upvotes: 5

Related Questions