Eric Abrahamsen <e...@ericabrahamsen.net> writes: > Okay, it's up. If anyone wants to explain to me the point of the > "where exists" clause in the SQL, I would be interested to hear. It > works as expected this way, but is that clause necessary?
Yes, very necessary. Without it, all ratings would be changed - the two example rows without ratings (ids 5 and 12) would get the values from the intermediary org table, every other row in table bookreview would get its rating attribute set to null (because there is no matching entry in the temporary updates table). Remember: update without a where clause always touches every single row of the complete table. The "where exists" clause ensures that only those rows of bookreviews are touched that are present in the intermediary org table. If you do not like "where exists" you could say "where bookreview.id in (select id from udpates)". -- Until the next mail..., Stefan.