Mysql select statement execution sequence

Source: Internet
Author: User

SELECT statement Definition
A complete SELECT statement contains several optional clauses. The SELECT statement is defined as follows:
<SELECT clause> [<FROM clause>] [<WHERE clause>] [<group by clause>] [<HAVING clause>] [<order by clause>] [<LIMIT clause >]
The SELECT clause is required. Other clauses, such as the WHERE clause and group by clause, are optional.
In a SELECT statement, the order of clauses is fixed. For example, the group by clause is not located before the WHERE clause.

SELECT statement execution sequence
The execution sequence of the SELECT statement substatements is different from that of the SELECT statement substatements. Therefore, the substatements are executed in the following order instead of starting from the SELECT clause:
Start> FROM clause> WHERE clause> group by clause> HAVING clause> order by clause> SELECT clause> LIMIT clause> final result
After each clause is executed, an intermediate result is generated for the subsequent clause. If no clause exists, skip

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.