Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有任何解决方案来查找由 MySQL groupby 查询分组的值的数量。以下是我的查询。 $groupBy = 'PropertyViewer.ip_address'; $this->paginate = array("group"=>array($groupBy),"order"=>array("PropertyViewer.id desc"));
$groupBy = 'PropertyViewer.ip_address';
$this->paginate = array("group"=>array($groupBy),"order"=>array("PropertyViewer.id desc"));
我需要找到在每种情况下分组的值。
我认为您需要的只是COUNT()SELECT 查询中的聚合函数:
COUNT()
SELECT COUNT( ip_address) as num_values FROM PropertyViewer GROUP BY PropertyViewer.ip_address ORDER BY PropertyViewer.id desc
SELECT count(PropertyViewer.ip_address) 将显示 IP 地址出现的次数(如果这是您要查找的内容)。