-1
重复计数和数据我有一个表像SQL选择表
+----+----------+------------+
| id | order_id | service_id |
+----+----------+------------+
| 1 | 3423343 | 123 |
+----+----------+------------+
| 2 | 3432356 | 124 |
+----+----------+------------+
| 3 | 2345643 | 123 |
+----+----------+------------+
| 4 | 2313343 | 125 |
+----+----------+------------+
我想是每个service_id
的数量,这将给输出这样
+------------+------+
| service_id | cout |
+------------+------+
| 123 | 2 |
+------------+------+
| 124 | 1 |
+------------+------+
| 125 | 1 |
+------------+------+
并且还把它排列在Highest -> Lowest
order
我正在CakePHP 3.2中工作
选择的service_id,计数(1)清点 从thetable 组通过的service_id 以通过COUT – splash58
可能的复制[CakePHP中:我如何计算一个找到的hasMany记录数(HTTP:/ /stackoverflow.com/questions/3123176/cakephp-how-do-i-count-the-number-of-hasmany-records-in-a-find) – sagi