In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces what the execution order of sql statements is, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article.
Sql statement execution order: 1, the first execution of from tab;2, where statement is to limit the conditions; 3, grouping statement [group by... Having]; 4, aggregate function; 5, select statement; 6, order by sort statement.
The execution order of sql statements:
1 、 from
Determine which table to fetch data from first, so from tab is executed first. There is a multi-table join, from tab1,tab2. Aliases can be added to the table to facilitate subsequent references.
2 、 where
The where statement qualifies the condition, and if there is no need to qualify, it is written as where 1, indicating that it is always true, with no conditions attached.
3. Group by. Having
Grouping statements, such as grouping by employee name, the fields to be grouped by row must appear in the select, otherwise an error will be reported. Having is used in conjunction with group by to qualify. Here is an example.
4. Aggregate function
The common aggregate functions are max,min and count,sum. The execution of aggregate functions comes after group by and before having. If you write aggregate functions in where, you will make an error.
5. Select statement
Select the fields you want to find, and if you select all, you can select *. The name of the employee and the total salary for all months are selected here.
6 、 order by
Sort statement, which defaults to ascending sort. If you want to sort in descending order, write order by [XX] desc. The order by statement is executed at the end, and can be sorted only if the select selects the fields to look for.
Thank you for reading this article carefully. I hope the article "what is the order of execution of sql sentences" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.