我有下表,我想在列 [code] 上做一个 select distinct,我不需要得到“A”三次。
[ ID ] [ CODE ] [ LIBELLE ]
1 A LIBELLE1
2 B LIBELLE2
3 C LIBELLE3
4 A LIBELLE4
5 A LIBELLE5
6 D LIBELLE6
我想要的结果如下
[ ID ] [ CODE ] [ LIBELLE ]
1 A LIBELLE1
2 B LIBELLE2
3 C LIBELLE3
6 D LIBELLE6
最佳答案
只需添加
group by code
ORDER BY code ASC
在你的 sql 查询结束时
示例
select * from table
group by code
ORDER BY code ASC
关于mysql - 在 mysql ( zend_db ) 上构建一个 select distinct,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3767639/