Initial knowledge of SQL execution order

Source: Internet
Author: User

Unlike normal program code, SQL executes in a certain order, and his first execution is always executed from the From, although select appears in the first position but the execution order is not the first one. Sometimes you may write a long code, not necessarily a good understanding of the SQL execution order. I can not understand it very well, so today I will tidy up the SQL execution order. Reference Example: @qanholas

Each step produces a virtual table that is used as input to the next step. These virtual tables are not available to callers (client applications or external queries). Only the table generated in the last step is returned to the caller. If you do not specify a clause in the query, the corresponding step is skipped.

(8)SELECT(9)DISTINCT( One)<TopNum> <SelectList>(1) from [left_table](3)<Join_type> JOIN <Right_table>(2) on <Join_condition>(4)WHERE <Where_condition>(5)GROUP  by <Group_by_list>(6) with <CUBE|RollUP>(7) having <Having_condition>(Ten)ORDER  by <Order_by_list>

In fact, I feel better in this example, so I borrowed it directly. So let's just get a quick look at his execution sequence process.

This is just my personal understanding. What's wrong with the hope of advice thank you.

Reference: http://www.cnblogs.com/qanholas/archive/2010/10/24/1859924.html

Initial knowledge of SQL execution order

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.