开发者

How to update the all the table values using a singe query

hai friends

i am having the table like this

TBLKEY      EMPKEY                         EMPNAME
----------- ------------------------------ ------------------------------
1           101                            RAJA
2           105                            RAJA
3           106                            RAJA
4           110                            RAJA

i want to to update like this

TBLKEY      EMPKEY                         EMPNAME
----------- ------------------------------ ------------------------------
1           101                            RAJA
2           105           开发者_如何学运维                 POOJA
3           106                            THRIU
4           110                            POOJA

here i sholud use only one query.i run that query i sholud get the output like this not updating one by one


Try it like this:

UPDATE myTable
SET EMPNAME = CASE WHEN TBLKEY = 2 THEN 'POOJA'
                   WHEN TBLKEY = 3 THEN 'THRIU'
                   WHEN TBLKEY = 4 THEN 'POOJA' END
WHERE TBLKEY IN ( 2, 3, 4 )


Have a look:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=96260

http://www.eggheadcafe.com/community/aspnet/13/10126702/update-single-column-with-multiple-rows.aspx

Sure this links will give you idea to proceed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜