| id | courseID | courseType |
+-----------+-------------+----+
| 1 | 0 | 2 |
| 2 | 2 | 2 |
| 3 | 0 | 0 |
| 4 | 10 | 4 |
| 5 | 2 | 2 |
| 6 | 0 | 0 |
| 7 | 0 | 0 |
| 8 | 5 | 2 |
| 9 | 5 | 2 |
| 10 | 5 | 2 |
+-----------+-------------+----+
我想列出,首先用CourseType所有CourseID作爲我sqlquery的可以顯示。熱門
| courseID | courseType |
+-----------+-----------+
| 5 | 2 |
| 2 | 2 |
| 10 | 4 |
+-----------+-----------+
如果你想獲得'courseId,courseType'對的出現次數,那麼你必須使用'group by' –