In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to use SQL for multi-table query". In daily operation, I believe many people have doubts about how to use SQL for multi-table query. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt of "how to use SQL sentence for multi-table query"! Next, please follow the editor to study!
There is Table 1: table 2: the following
Id info id value
1 a 1 10
2 b 2 30
3 c
4 d
Want to get
Id value
1 10 / / exists in Table 2
2 20 / / exists in Table 2
3 0 / / does not exist in Table 2
4 0 / / does not exist in Table 2
Whether it can be solved by using a sql statement without having to get id from Table 1, and then find out whether there is a record in Table 2. If so, read it directly. If not, the value is assigned to 0.
The copy code is as follows:
Select Table 1. Idline is null (value,0) from Table 1
Table 2 of left join
On Table 1.id = Table 2.id
The copy code is as follows:
Select a. Id is null (b. Value1 0) from Table 1 a
Table 2 b of left join
On a.id=b.id
At this point, the study on "how to use SQL statements for multi-table query" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.