Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Oracle rookie learning complex update statements to use

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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 >

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report