Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> SQL UPDATE of one table based on values of another table -- is it possible?
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