I came across SQL behavior that I don't understand. I needed to update several rows in a table at once; started with their search:
SELECT * FROM some_table WHERE field1 IN (SELECT ...)
This returned a selection of about 60 rows. Now I was pretty sure that I got the subquery on the right, so I only changed the first part:
UPDATE some_table SET field2 = some_value WHERE field1 IN (SELECT ...)
In other words, it was exactly the same as the first query after WHERE . However, this led to an update of 0 rows, whereas I would expect these 60. Please note that the above statement would change the value of field2 , that is, I checked that some_value not present in the selected rows.
The subquery was a modestly complex SQL part with two (different) tables, 1 view, a join, and its own WHERE . In case it matters, it happened with Oracle Database 10g.
So the question is, why didn't UPDATE touch the rows returned by SELECT ?
source share