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