MySQL mandatory meeting-notes

Source: Internet
Author: User

1. Common SQL:

A. Show databases;

B. Use xxx

C. Show tables;

D. Show columns from XXX; (describe XXX)

2. Group:

A. The group by clause can contain any number of columns. This allows grouping to be nested to provide more detailed control for data analysis.

B. If a group is nested in the group by clause, the data is summarized in the group specified at the end. In other words, when a group is created, all specified columns are calculated together (so data cannot be retrieved from individual columns ).

C. Each column listed in the group by clause must be a search column or a valid expression (but not a clustering function ). If an expression is used in select, the same expression must be specified in the group by clause. Aliases cannot be used.

D. Except for the aggregate calculation statement, each column in the SELECT statement must be given in the group by clause.

E. If the group column has a NUL value, null is returned as a group. If the column contains multiple null values, they are divided into one group.

F. The group by clause must appear after the WHERE clause and before the order by clause.

3. Differences between having and where:

Where is used to filter the data group money and having is used to filter the data group money.

4. Order by and group:

Order

Group

Output by sorting

Group rows, but the output may not be the group order

Any column can be used (or even non-selected columns)

Only select columns or expression columns can be used, and each selection column expression must be used.

Not necessarily required

If you use a column (or expression) with an aggregate function, you must use

Refer:

MySQL required

Thomesca (beicai): http://blog.csdn.net/thomescai
(Reprinted and retained)

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.