In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to use a SQL statement to remove the same data in two tables and then accumulate the same data in the third table". The content in the article is simple and clear, and it is easy to learn and understand. below, please follow the editor's train of thought to study and learn "how to use a SQL statement to remove the same data in two tables and accumulate the same data in the third table".
Table X:
A B C D
-
Beijing Guangzhou 1000 10
Beijing and Shenzhen 1200 20
Beijing and Shanghai 500 30
Beijing Tianjin 300 40
Beijing Henan 800 20
Table Y:
A B
-
Beijing and Shenzhen
Beijing and Shanghai
Table Z:
A B C D
-
Beijing Guangzhou 200 10
Beijing and Shanghai-100-10
Beijing Sichuan 800 50
Objective: to remove the data with the same keyword in Table Y from Table X, and add the data in Table Z to accumulate the same keyword (AMagi B is the keyword).
The results are as follows:
A B C D
-
Beijing Guangzhou 1200 20
Beijing and Shanghai 400 20
Beijing Henan 800 20
Beijing Sichuan 800 50
The copy code is as follows:
Select an as d from bstatement sum (c) as c
(select * from x union all select * from z) t
Where not exits (select 1 from y where y.a=t.an and y.b=t.b)
Group by a,b
Thank you for your reading, the above is "how to use a SQL statement to remove the same data in two tables and then accumulate the same data in the third table". After the study of this article, I believe you have a deeper understanding of how to use a SQL statement to remove the same data in two tables and accumulate the same data in the third table. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.