0

Hello people here is my query

UPDATE `talent2db`.`talent_employee` SET `Rec_Status` = 'I' WHERE `talent_employee`.`Emp_Id` = '241074' AND `talent_employee`.`Rec_Status` = 'A' ;

UPDATE `talent2db`.`talent_employee` SET `Rec_Status` = 'I' WHERE `talent_employee`.`Emp_Id` = '785062' AND `talent_employee`.`Rec_Status` = 'A' ;

BY USING ABOVE QUERY IAM TRYING TO set "rec_status" to 'I' from 'A',as we can see we are trying to update for two employess with two different emp_ids... is it possible to update by writing only one query ...?? it should be something like

UPDATE `talent2db`.`talent_employee` SET `Rec_Status` = 'I' WHERE `talent_employee`.`Emp_Id` = '785062,241074' AND `talent_employee`.`Rec_Status` = 'A' ;

3 Answers 3

1

You can use condtion like this (talent_employee.Emp_Id = '785062,241074' OR talent_employee.Emp_Id = '785062')

following is the actual query

UPDATE `talent2db`.`talent_employee` SET `Rec_Status` = 'I' WHERE (`talent_employee`.`Emp_Id` = '785062,241074' OR `talent_employee`.`Emp_Id` = '785062') AND `talent_employee`.`Rec_Status` = 'A' ;
Sign up to request clarification or add additional context in comments.

Comments

0

try using IN clause.

UPDATE `talent2db`.`talent_employee` 
SET `Rec_Status` = 'I' 
WHERE `talent_employee`.`Emp_Id` IN ('785062','241074') AND 
      `talent_employee`.`Rec_Status` = 'A' ;

Comments

0

Use the OR clause.

UPDATE `talent2db`.`talent_employee` 
SET    `rec_status` = 'I' 
WHERE  (`talent_employee`.`emp_id` = '785062' OR `talent_employee`.`emp_id` = '241074') 
AND `talent_employee`.`rec_status` = 'A'; 

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.