- Chung
- 0°C
- 13 年又 125 天
用distinct在MySQL中查詢多條不重複記錄值
select *, count(distinct name) from table group by name
結果:
id name count(distinct name)
1 a 1
2 b 1
3 c 1
group by 必須放在 order by 和 limit之前,不然會報錯.
更簡單的解決方法:
select id, name from table group by name
台北市松山區八德路四段650號 Go
- 1,871
- 0
- 0

