tags:

views:

30

answers:

3

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
Where 'easy' and 'hard' are quite the personal experience. :)
Tobiasopdenbrouw
+2  A: 

you can use IN operator

update table1
set date=<your date>
where userid in (1,2,3,.....10)
Anil
+1 Cheers, you read the question better than I did :)
Andomar
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