Re: Update from multiple tables
Date: Tue, 31 Dec 2002 01:33:17 GMT
Message-ID: <xt6Q9.97211$pe.3586499_at_news2.east.cox.net>
There are other ways, but this is my favorite. Also, I believe T1 must be "key preserved" or something like that.
update
(select t1.*, t2.field2 t2_field2
from T1, T2
WHERE T1.Field1 = T2.Field1 AND T1.Field3 = T2.Field3) SET Field2 = T2_Field2
"Okey Laboratory" <N/A> wrote in message
news:H7y8o5.9ws_at_campus-news-reading.utoronto.ca...
> Hi all,
>
> I'm not sure if this is the right place for a SQL problem. If not, any
> advice on where to look would be very much appreciated.
>
> On Oracle 9i, I have two tables:
>
> T1(
> Field1 NOT NULL
> Field2
> Field3 NOT NULL)
>
> T2(
> Field1 NOT NULL
> Field2 NOT NULL
> Field3 NOT NULL
> )
>
> I would like to update T1.Field2 based on T2.Field2.
> That is, I really want something like:
>
> UPDATE T1, T2
> SET T1.Field2 = T2.Field2
> WHERE T1.Field1 = T2.Field1
> AND T1.Field3 = T2.Field3
>
> Of course I can't specify multiple tables in the UPDATE clause. I *SWEAR*
> I've solved this problem in a reasonably efficient manner in the past, but
I
> can't seem to find a work-around now. Any suggestions?
>
> Tats
>
>
Received on Tue Dec 31 2002 - 02:33:17 CET