How can I update a column in a table with the result of a select statement that uses row being updat
Posted
by Sailing Judo
on Stack Overflow
See other posts from Stack Overflow
or by Sailing Judo
Published on 2010-03-22T18:46:06Z
Indexed on
2010/03/22
18:51 UTC
Read the original article
Hit count: 129
sql
This SQL statement example is very close to what I think I need...
update table1 set value1 = x.value1 from
(select value1, code from table2
where code = something) as x
However, what I need to do is change the "something" in the above example to a value from the row that is being updated.
For example, I tried this but it didn't work:
update table1 A set value1 = x.value1 from
(select value1, code from table2
where code = A.something) as x
This is a one time operation to update an existing table and I'm not really looking for high performance way to do this. Any solution that gets the task done is good enough.
© Stack Overflow or respective owner