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

Home -> Community -> Usenet -> c.d.o.server -> SQL UPDATE of one table based on values of another table -- is it possible?

SQL UPDATE of one table based on values of another table -- is it possible?

From: <johnvue_at_gte.net>
Date: Thu, 18 Nov 1999 06:05:48 GMT
Message-ID: <38339718.85619874@news.gte.net>


Is there a way to construct an SQL UPDATE statement to update one table based on values of another table? The statement below doesn't work. I was hoping to avoid writing a PL/SQL loop to do this.

The following SQL doesn't work but shows what I'm trying to do:

 update t1
 set t1.class = t2.class
 from t1, t2
 where t1.animal = t2.animal;

table t1:                       table t2:            
---------------------           ---------------------
                                                     
animal      class               animal      class    
---------   ---------           ---------   ---------
cat         unknown             cat         mammal   
frog        unknown             frog        amphibian
alligator   unknown             alligator   reptile  
beetle      unknown             beetle      insect   
pigeon      unknown             pigeon      bird     
salmon      unknown             salmon      fish

              ^                               ^
              |___replace this column_________|
Received on Thu Nov 18 1999 - 00:05:48 CST

Original text of this message

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