Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Update and select for the same table

679182Jul 19 2009 — edited Jul 19 2009
Hello frnds,


I am trying to select and updat the same table. example:

Frist table:
SQL> select * from t_1;

        NO F            BKAC_SID
---------- ---------- ----------
         1 f1
         2 f2
         3 f3

second table:

SQL> select * from bkac;

        NO F                ORDR   BKAC_SID
---------- ---------- ---------- ----------
         1 f1                 10       1111
         2 f1                 20       1111
         3 f2                 100     2111
         4 f2                 200     2110
Now, I need to Update bkac_sid in "t_1" table.

Matching condition is on "F" and update the minimum order obtained.
SQL> select min(ordr) from bkac where f = 'f1';

MIN(BKAC_SID)
-------------
         10
For order number 10, bkac_sid = 1111

UPDATE table t_1:
SQL> select * from t_1;

        NO F            BKAC_SID
---------- ---------- ----------
         1 f1           1111
         2 f2           
         3 f3
I just want to write one update statement.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 16 2009
Added on Jul 19 2009
3 comments
3,155 views