+------+---------+
| id | object |
+------+---------+
| 1 | 1 |
| 1 | 2 |
| 1 | 3 |
| 1 | 4 |
| 2 | 3 |
| 2 | 4 |
| 3 | 5 |
| 3 | 3 |
| 3 | 4 |
+------+---------+
我想选择具有相同值的count id,因此结果是,id 1有4个相同的值,id 2有2个相同的值,id 3有3个相同的值。
+------+
| id |
+------+
| 4 |
| 2 |
| 3 |
+------+
感谢您的帮助,掌握。
答案 0 :(得分:1)
SELECT id, COUNT(object) FROM tablename GROUP BY id
答案 1 :(得分:1)
SELECT COUNT( * ) FROM `test` GROUP BY id