0

I have used following the Table(emp) in my product.

id  - name - Manager - dept- ismanager
101 - XXX  - YYY - 1-0
102 - XX   - YY  - 2-0
103 - XXX  - YYY - 1-0
104 - XX   - YY  - 2-0
105 - XXX  - kkk - 2-0
106 - XX   - zzz - 2-0
107 - XXX  - YYY - 2-0

I want to update the isManager column value as 1, when the manager is YYY/YY. because those are repeatable in my Table. How can I solve it? I have tried to check condition in where like "update emp SET ismanager = '1' where Manager = 'YYY' and Manager = 'YY'; but in that case table will hit many times and I dont know about the what the value stored in the manger column. It will change runtime. Basically i want to know, if the 'manager' column value is repeated, I will update 'ismanager' column as '1'. Please Suggest me. How to do that?

This is, i can achieved as per CL(below) suggestion. Thanks CL.

1 Answer 1

1
UPDATE emp
SET ismanager = 1
WHERE Manager IN (SELECT Manager
                  FROM emp
                  GROUP BY Manager
                  HAVING COUNT(*) > 1)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.