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

> -----Original Message-----
> From: Rod Clayton [mailto:[EMAIL PROTECTED]]
>
> 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

Reply via email to