Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick Update question

Status
Not open for further replies.

teknikalbody

Programmer
Mar 2, 2003
35
GB
Hi,

I have a query as below;


select A.Value
from TABLE_A A,
TABLE_B B
where A.code in
(select C.code
from TABLE_C C
where C.code = A.code
and C.Value !=A.Value)
and A.Value = B.Value

Can someone please suggest how I may update the C.Value on TABLE_C with the A.Value this query returns?

Thank you.
 
You will need to modify your query before using it in an UPDATE. It looks like the query could potentially return more than one row.

You can use a select to update like this, provided the select will return only one row for each row you want to update:

Code:
UPDATE table1
SET    column1 = (select column2              
                  from   table2
                  where  table2.table1_id = table1.id);

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top