Update statement where update exists. [message #613259] |
Thu, 01 May 2014 15:03  |
tmcallister
Messages: 107 Registered: December 2007
|
Senior Member |
|
|
I have a query of the following form:
UPDATE address ad
SET (area_id, street_id) =
<COMPLICATED QUERY>
WHERE EXISTS
<result from COMPLICATED QUERY>
And I can't help but think there has to be a way to write this without duplicating the <COMPLICATED QUERY>. Any tips?
|
|
|
Re: Update statement where update exists. [message #613260 is a reply to message #613259] |
Thu, 01 May 2014 15:32   |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
Why do you want to avoid the EXISTS clause?
It is there to make sure that only those records which are picked in the subquery are updated, else all the records would be updated. And just imagine what would the update do to those records which are not in the subquery? I don't see any harm with the EXISTS clause.
|
|
|
|
|
|
|
|