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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Newbie Help! Simple update question

Re: Newbie Help! Simple update question

From: Ales Voboril <alesv_at_post.cz>
Date: Wed, 18 Jul 2001 11:44:21 +0200
Message-ID: <3b555a59$1@news.cvut.cz>

Hello,

SQL> select * from table1;

  KEYFIELD STATUS
---------- ------

         1 A
         2 B

SQL> select * from table2;

  KEYFIELD STATUS
---------- ------

         1 C
         2 D

SQL> update table2 set status = (select status from table1 where table1.keyfield=table2.keyfield) where table2.keyfield=1;

1 row updated.

SQL> select * from table2;

  KEYFIELD STATUS
---------- ------

         1 A
         2 D

HTH,
Ales

Robert Blomstrand <rbl_at_qmedia.co.za> wrote in message news:3b5544d6$0$234_at_helios.is.co.za...
> Could I please ask a simple question that has been bugging me for a long
> time. Any suggestions would be greatly appreciated...
>
> You have 2 tables (lets say "table1" and "table2") linked together with a
> key (lets call the column "keyfield"). Both tables also contain column
 that
> we could name "status".
>
> How would I now go about updating the "status" column on table2 with the
> same value of the "status" column on the corresponding table1 row. I could
> do this with a little PL/SQL script using a cursor but surely there is a
 way
> of doing it through a single update command?
>
> I would really appreciate an answer on this one, and please copy any
 replies
> to both this newsgroup and my E-mail rbl_at_qmedia.co.za.
>
> Many thanks all.
>
>
Received on Wed Jul 18 2001 - 04:44:21 CDT

Original text of this message

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