I want to update the values of a record using itself and the values from another row without using a bunch of selects in the set portion of the query to combine the 2. Assume you already know the primary keys of both rows.
Here's an example of what should happen before and after:
Before:
| pk_id|allocated|purchased|installed|
| 10| 2| 5| 10|
| 3| 8| 6| 2|
| 11| 2| 6| 7|
After:
| pk_id|allocated|purchased|installed|
| 10| 2| 5| 10|
| 3| 8| 6| 2|
| 11| 4| 11| 17|
I want to NOT have to do something like this:
UPDATE Example
set allocated = (select allocated from Example where pk_id = 10)
+ (select allocated from Example where pk_id = 11),
purchased = (select purchased from Example where pk_id = 10)
+ (select purchased from Example where pk_id = 11),
installed = (select installed from Example where pk_id = 10)
+ (select installed from Example where pk_id = 11)
WHERE pk_row = 11
All of those selects seem REALLY unnecessary, but I can't think of a better way.