tags:

views:

59

answers:

3

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

+5  A: 

Like this, using IN:

 UPDATE `myTable` SET `todo_deleted` = 1 WHERE `id` IN (23, 25, 26)
nickf
+4  A: 
UPDATE TABLE
SET COLUMN = NEW VALUE
WHERE ID IN ( 23, 25 ,26 )
IordanTanev
+1  A: 

Great...Thanx for all....... I got my required output..

This is not an answer :)