[MySQL] query filter on, where, having

Source: Internet
Author: User
Execution sequence:First, on, where, and having. Usage:On: On is used for filtering when multi-table join queries are performed. On first, it filters out data that does not meet the query conditions, thus reducing the number of data operations during the Query Process. Where: after a temporary table is queried, it is executed before data computing. Because the data has not been grouped and the row and column selection operations Where cannot be applied(1) Use the column alias, for example, select name as N from TB where n = 'xiaohua'; (2) use the statistical method (Min, Max, sum, etc ), for example, select *, ID from TB where count (ID) <2; having: The having operation is meaningful only when group by is used. Having is executed after data computing. Summary:(1) Multi-table join queries do not require on filtering. (2) In a single table query, if the select field does not involve the calculation process, the where and having results will be the same after execution.

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.