How can i write an sql script for updating 10 row's date for 10 different users
A:
The easy way:
update users
set name = 'Joe'
where userid = 1
update users
set name = 'Mohammed'
where userid = 2
Etc.
The hard way:
update users
set name = case when userid = 1 then 'Joe'
when userid = 2 then 'Mohammed'
...
else name
end
Andomar
2010-08-26 09:04:55
Where 'easy' and 'hard' are quite the personal experience. :)
Tobiasopdenbrouw
2010-08-26 09:18:54
+2
A:
you can use IN operator
update table1
set date=<your date>
where userid in (1,2,3,.....10)
Anil
2010-08-26 09:07:27
A:
Another option
update Table_name set value = something
where column_name in (select values from list_table);
Here you all values in temp table and use that table as mentioned above.
Pravin Satav
2010-08-26 10:19:56