Oracle rookie learning complex update statements to use
Oracle rookie learning complex update sentences use examples and answers
Question: there are three fields in table T1 and three fields in table T2. If "c" in table T1 is the same as "c" in table T2, what can I do if "c" in table T2 is the same as "c" in table T2?
Experimental table:
Create table T1 (an int,b int,c int,d int,e int); create table T2 (an int,b int,c int); insert into T1 values (1); insert into T1 values (10); values (10); insert into T2 values (- 1); insert into T2 values (- 2).
View the table:
SQL > select * from T1; A B C D E-1 2 3 4 4 5 10 20 20 3 4 5 10 20 4 40 50SQL > select * from T2 A B C-1-13-2-2 4SQL >
Train of thought:
Basic statements for updating data
Update T1 set axioms? Where?
How to choose a?
SQL > select a.a from T2, T1 b where a.cedb.c; A-- 1-1-2SQL >
B can also be selected.
SQL > select a.b from T2, T1 b where a.cedb.c; B-- 1-1-2SQL >
What is where? How do I get a unique value from the collection?
SQL > update T1 set a = (select a from T2 where T1.c=T2.c), b = (select b from T2 where T1.c=T2.c) where T1.c in (select c from T2); 3 rows updated.SQL >
View the result
SQL > select * from T1 A B C D E-1-1 345-1-1 345-2-2440 50SQL >