Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Updating table a from table c through table b.

RE: Updating table a from table c through table b.

From: Jacques Kilchoer <Jacques.Kilchoer_at_quest.com>
Date: Tue, 08 Jan 2002 12:53:45 -0800
Message-ID: <F001.003EA31A.20020108123525@fatcity.com>

> -----Original Message-----
> From: Rod Clayton [mailto:rclayton_at_mail.howard.k12.md.us]
>
> I have a field in a table called C called ID that I want to
> use to update a field in table A called ID. 
>
> Table A has a key to table B which has a key to table C.
>
> I can not find a working example of doing this. 
>
> Does anyone have a suggtion.  I have been using the examples
> in the Oracle manuals, but I can't seem to get one to work.

Here's an example:

LQS> select * from a ;

         K         ID
---------- ----------
         1
         2

LQS> select * from b ;

         K         K2
---------- ----------
         1         11
         3         33

LQS> select * from c ;

        K2         ID
---------- ----------

        11        111
        22        222
        33        333
        44       4444


LQS> update a set a.id = (select c.id from b, c where b.k = a.k and c.k2 = b.k2)   2  where exists (select * from b, c where b.k = a.k and c.k2 = b.k2) ;

1 ligne mise à jour.

LQS> select * from a ;

         K         ID
---------- ----------
         1        111
         2 Received on Tue Jan 08 2002 - 14:53:45 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US