Query the execution sequence of select from where group by having order by in a statement

Source: Internet
Author: User
Tags select from where

In the query statement, select from where group by having order by is executed in sequence 1. the query mainly contains six keywords, and their order is select -- from -- where -- group by -- having -- order by, where select and from are required, other keywords are optional. The execution sequence of these six keywords is not the same as that of SQL statements, instead, execute from -- where -- group by -- having -- select -- order by in the following order, from: the data table from which to retrieve data where: filter the data condition group: how to group the data that has been filtered out above having: filter the data that has been grouped above the condition select: view which column in The result set, or the calculation result order by of the column: view the returned data in what order. 2. table association after from, which is from the right The resolution order of the where condition is bottom-up. That is to say, when writing SQL files, try to put tables with a large amount of data on the rightmost side for association, and put the conditions that can filter out a large amount of data at the bottom of the where statement.

Related Article

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.