views:

38

answers:

2

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

+5  A: 

Hi,
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 )

Best Regards,
Iordan

IordanTanev