|
-
Oct 11th, 2006, 07:40 PM
#1
Thread Starter
Fanatic Member
Oracle syntax for update with a value from two other tables
I have a table I need to update with a value from two other tables. What's the syntax? Obviously not the same as SQL Server. I may have figured out the need for a subquery, but how do I link the value returned from the subquery to the table being updated?
Table 1 - needs to be updated
Table 2 - links to Table 1
Table 3 - links to Table 2 and has the value needed for the update
' here's a stab at it but it's not quite right:
UPDATE Table1
SET myDateDueValue = (SELECT P.DATEDUETOREP from Table2 U, Table3 P
WHERE P.PROPOSALNUMBER = U.RP_ProposalNumber AND U.RP_PROPOSALNUMBER <> 0) SQ
WHERE REQUESTID = SQ.REQUESTID;
-
Oct 12th, 2006, 03:31 AM
#2
Re: Oracle syntax for update with a value from two other tables
Usual one is something like :
Code:
Update Table1, (SELECT P.DATEDUETOREP from Table2 U, Table3 P
WHERE P.PROPOSALNUMBER = U.RP_ProposalNumber AND U.RP_PROPOSALNUMBER <> 0
) SQ
WHERE table1.REQUESTID = SQ.REQUESTID
SET myDateDueValue = sq.DATEDUETOREP
Please note - I may have got that second where clause in the wrong place...
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|