We help IT Professionals succeed at work.

SQL - Update column per Emp

CipherIS
CipherIS asked
on
So, I have a table, lets say with the following cols/data

EMPID     Value01    Value02   Value03
0001        Test01      Test02      0
0001        Test02      Test03      0
0001        Test04      Test05      0
0002        Test01      Test02      0
0002        Test02      Test03      0
0002        Test04      Test05      1
0003        Test01      Test02      0
0003        Test02      Test03      0
0003        Test04      Test05      1

So, what is important is columns EMPID and Value03.  The other columns are irrelevant.  Basically what I need to do is if the value in column Value03 = 1 then update that column = 1 for that EMPID.  

So EMPID -> 003 would have a value 1 in each Value03 column and same for EMPID ->002
Comment
Watch Question

Contract ERP Admin/Consultant
Commented:
Try this:

UPDATE YourTable
SET VALUE03 = 1
WHERE  EMPID IN ( SELECT EMPID FROM YourTable
                         WHERE VALUE03 = 1)
AND VALUE03 = 0

Author

Commented:
That did it.