Home » SQL & PL/SQL » SQL & PL/SQL » Select in update
Select in update [message #18359] Tue, 29 January 2002 08:41 Go to next message
Tarun bhagwan
Messages: 1
Registered: January 2002
Junior Member
How do I do an select in update.

THe query
UPDATE vrts_drs_order_header h
SET h.account_id = a.account_id
FROM account_profile a
WHERE h.customer_id = a.customer_id

fails with the error --
FROM ACCOUNT_PROFILE WHERE
*
vrts_drs_order_header.customer_id =ACCOUNT_PROFILE.customer_id


This means that the query is syntatically wrong ... SQL is not expecting a from clause there. Isn't the following the update syntax defn.
UPDATE [[ ONLY ]] table SET col = expression [[, ...]] [[ FROM fromlist ]] [[ WHERE condition ]]

Please help.

regards
Tarun
Re: Select in update [message #18361 is a reply to message #18359] Tue, 29 January 2002 08:51 Go to previous message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
UPDATE vrts_drs_order_header h
SET h.account_id = (SELECT a.account_id
FROM account_profile a
WHERE h.customer_id = a.customer_id )
Previous Topic: how to create table with structure only based on another table with data
Next Topic: Where's the PL/SQL STANDARD package reference?
Goto Forum:
  


Current Time: Thu Mar 28 16:56:22 CDT 2024