mysql group by

常用group by去找資料的方式:
找出資料表中男性跟女性的人數

SELECT sex, COUNT(*) FROM table GROUP BY sex;

當資料表中有重覆的資料時,而又只是想顯示一筆:
資料表中有六筆資料,但出現重覆
1.test
2.test
3.test
4.haha
5.haha
6.haha

SELECT name FROM table GROUP BY name;
結果:
1.test
2.haha

沒有留言: