Re: Update and from
From: C. Derek Fields <derek_at_candyland.gamekeeper.bellcore.com>
Date: 13 Jan 1994 16:03:19 GMT
Message-ID: <2h3rc7$lo3_at_athos.cc.bellcore.com>
Date: 13 Jan 1994 16:03:19 GMT
Message-ID: <2h3rc7$lo3_at_athos.cc.bellcore.com>
In article <jdennisCJJ7G4.4zJ_at_netcom.com>, jdennis_at_netcom.com (John Dennis) writes:
|> For example, I have two tables, TABLE1 and TABLE2 which
|> have the columns KEY, A and B. Now I want to put TABLE1's A and B
|> values into TABLE2 WHERE TABLE1.KEY = TABLE2.KEY. It doesn't seem
|> obvious how I can do this (in Oracle). In Sybase I'd use:
|>
|> UPDATE TABLE2
|>
|> FROM TABLE1 T1,
|> TABLE2 T2
|> SET T2.A = T1.A,
|> T2.B = T1.A
|>
|> WHERE T1.KEY = T2.KEY
|>
|> So, Oracle SQL experts, what is the clear (foggy to me) way to do
|> this?
|>
|> Thanks in advance,
|> John
|>
Try this:
update table2
set (a,b) =
(select a, b
from table1
where table1.key = table2.key)
-- Derek Fields (derek_at_gamekeeper.bellcore.com)Received on Thu Jan 13 1994 - 17:03:19 CET