Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
dear

i want to update more than one values of name column ...

like

table1

id name
1 a
2 b
3 c
4 d
5 e
6 f
7 g
8 h
9 k

i want to update name of id 1,4,6,9
Posted
Comments
Sergey Alexandrovich Kryukov 16-Mar-13 1:42am    
Please stop posting non-answers as "solution". It can give you abuse reports which eventually may lead to cancellation of your CodeProject membership.
Comment on any posts, reply to available comments, or use "Improve question" (above).
Also, keep in mind that members only get notifications on the post sent in reply to there posts.
—SA

Hi ,
Check this
SQL
update table1
set 
name= 'test'
where 
ID in (1,3,5)

Best Regards
M.Mitwalli
 
Share this answer
 
SQL
Update t
SET Name = Case When name = 'a' then yy
                When Id = 'b' then zz
                ......
                End
FROM <mytable> t
WHERE id IN (1,2,5,9)
 
Share this answer
 
v2
Comments
Mohamed Mitwalli 18-Feb-13 8:53am    
5+
Arun1_m1 18-Feb-13 8:57am    
What does 5+ mean ?? Sorry I am new to the community
Mohamed Mitwalli 18-Feb-13 9:39am    
I vote for your answer 5 Star and your Gain more Points :)
Check this link http://www.codeproject.com/script/Membership/Reputation.aspx[^]
Update table1 set name = 'newName1' where id = 1;
Update table1 set name = 'newName3' where id = 3;
Update table1 set name = 'newName7' where id = 7;
 
Share this answer
 
Hi
Do simple WHERE Clause with "IN" Operator.

SQL
UPDATE <tablename> SET Column_Name=<new_value> WHERE ID IN(1,2,5,9)
</new_value></tablename>


Regards,
GVPrabu
 
Share this answer
 
Hi Mukesh ,

You Can use Case statement for updatation .


SQL
Update tblname Set name= 
                   case when id=1 then 'Aone'
                   Case when iD= 4 then 'Afour'
                   case when id= 7 then 'Aseven'
                   End
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900