I have the following query, in which I try to put everything so that I only need to execute the query once for optimization (oracle 12c DBMS).
update PersonStatus s
set s.status = 4
where exists (
select 1 from PersonStatus s1
inner join Person p
on s1.id = p.id
where p.details = 'california' and s1.status = 0 and s1.age in (1,2,3,4,5)
)
Tables:
Person (id, details)
PersonStatus(id, status, age)
where id in PersonStatus references id in Person. Note that I simplified/renamed the tables just for demo purposes.
Basically, I just want to update the rows that match the condition in where exists (....), but I didn't seem to get it.
When I execute this, it updated all the rows in the table, but what I need is to update only those rows that have age in the given list (1,2,3,4,5). This is for Oracle 12c database.
Any idea why the behavior is like that? Suggestions are appreciated.
===== in MySQL. my following query works fine:
update PersonStatus s
inner join Person p on s.id = p.id
set s.status = 4;
where p.details = 'california' and s.status = 0 and s.age in (1,2,3,4,5)
I try to achieve this in Oracle 12c.