In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail about the mysql sub-query is generally divided into several types, the editor thinks it is very practical, so share it for you to do a reference, I hope you can get something after reading this article.
1. Basic knowledge of MySQL subquery
The subquery is to embed the new query in the original query statement to get the result set we want.
Subqueries are generally divided into where subqueries, from subqueries and lies subqueries.
1.where subquery: use the results of the inner query as a comparison condition for the outer query.
Select column 1, column 2 in., column n from table name where column I = / in (select column 1, column 2 in, column n from table name where.)
2.from subquery: treat the query result of the inner layer as a temporary table for the outer sql to query again. Query result sets can be treated as tables. Temporary tables use an alias.
Select column 1, column 2 from. Column n from (column select column 1, column 2 from table name where.) As table alias where.
3.exists subquery: take the results of the outer sql to the inner sql to test. If the sql of the inner layer is established, the line is taken out. The inner query is the query after exists.
Select column 1, column 2 from..., column n from table name where exists (select column 1, column 2 from table name where.)
Second, query instances
The following picture shows the data of grade table and class table.
1. Query the information of the students with the highest math scores in the score table.
two。 Query the highest total scores of each class in the score table
3. According to the grade table and class table, find out the classes with missing grades in the score table.
On the "mysql sub-query is generally divided into several" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.
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.