Mysql deduplication query _ MySQL

Source: Internet
Author: User
Mysql deduplication query bitsCN.com

Mysql deduplication query

The group by statement can deduplicate a column.

Directly run the following statement:

Select io_dev_id from io_info where (TID = 1 AND host_name = 'ang1') group by 1;

Deduplicate query by io_dev_id.

P: use order by and distinct.

Group by is selected based on columns

Order by is sort BY column

Distinct is similar to group by, but can only be placed behind select, before the filtered field.

For example, select distinct a, B, c from tb1;

Select data with the same values in column a, column B, and column c.

Extracted content from mysql 5.6 reference manual:

In most cases, a DISTINCT clause can be considered as a special case of group. for example, the following two queries are equivalent: select distinct c1, c2, c3 FROM t1WHERE c1> const; SELECT c1, c2, c3 FROM t1WHERE c1> const group by c1, c2, c3;

BitsCN.com

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.