Mysql deduplication Query

Source: Internet
Author: User
Welcome to the Linux community forum, and interact with 2 million technical staff to enter the GROUPBY statement to implement deduplication query for a certain column. Directly run the preceding statement: selectio_dev_idfromio_infowhere (Tyang1) GROUPBY1; deduplication by io_dev_id. P: add it with ORDERBY and disti.

Welcome to the Linux community forum and interact with 2 million technical staff> enter the group by statement to implement deduplication query for a certain column. Directly run the preceding statement: select io_dev_id from io_info where (TID = 1 AND host_name = 'yang1') group by 1; deduplication BY io_dev_id. P: Add order by and disti.

Welcome to the Linux community forum and interact with 2 million technicians>

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 by. For example, the following two queries are equivalent:

Select distinct c1, c2, c3 FROM t1

WHERE c1> const;

SELECT c1, c2, c3 FROM t1

WHERE c1> const group by c1, c2, c3;

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.