David Bass
asked on
Update a SQL Table if conditions are true.
I need to UPDATE a Oracle DB. I am learning SQL, so please forgive my newbie question.
I have successfully created this Oracle SQL Query
Select person.personnum from person
join vp_allperson on
person.personnum = vp_allperson.personnum
where vp_allperson.employmentsta tus = 'Terminated' and person.fingerrequiredsw = 1;
I would like instead of returning my results of personnum, I would like to update person.fingerrequiredsw from 1 to 0 if both the above conditions are true.
I am just not sure how?
Thank you for looking
David
I have successfully created this Oracle SQL Query
Select person.personnum from person
join vp_allperson on
person.personnum = vp_allperson.personnum
where vp_allperson.employmentsta
I would like instead of returning my results of personnum, I would like to update person.fingerrequiredsw from 1 to 0 if both the above conditions are true.
I am just not sure how?
Thank you for looking
David
ASKER
In my SQL statement, I am using a SELECT statement to show me the results of where both conditions are true.
It displays the personnum field if both conditions are true. It does that just fine.
All this does is compare that both results are true.
My outcome is that I do not want these to be true.
The first condition checks if a person is terminated, and they have a fingerrequired flag set to 1.
I want to limit my fingerrequired to only active employees. So if they are terminated then make this field, person.fingerrequired from 1 to 0. to 0 = off. 1 = on.
I hope that makes it clearer.
Thanks
It displays the personnum field if both conditions are true. It does that just fine.
All this does is compare that both results are true.
My outcome is that I do not want these to be true.
The first condition checks if a person is terminated, and they have a fingerrequired flag set to 1.
I want to limit my fingerrequired to only active employees. So if they are terminated then make this field, person.fingerrequired from 1 to 0. to 0 = off. 1 = on.
I hope that makes it clearer.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
Happy to help.
For both of the conditions to be true, fingerrequiredsw is already 1 based on your where clause.