bitscn.com
group by 语句可以实现某一列的去重查询。
直接上语句:select io_dev_id from io_info where (tid=1 and host_name='yang1') group by 1;按照io_dev_id去重查询。 p:顺手加上与order by 和 distinct的区分使用group by 是根据列捡选order by 是根据列排序distinct类似于 group by ,但是只能放在 select 后面,被筛选的字段前面。如:select distinct a,b,c from tb1;选出的是a、b、c三列值都相同的数据。 摘取的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 t1where c1 > const;select c1, c2, c3 from t1where c1 > const group by c1, c2, c3;bitscn.com