我正在使用RedBeanPHP,我想知道一列的最重复值。
我有这个:
$books = R::getAll('
SELECT `autor`,
COUNT(`autor`) AS `value_occurrence`
FROM `fichas`
GROUP BY `autor`
ORDER BY `value_occurrence` DESC
LIMIT 10
');
foreach( $books as $book ) {
echo $book['autor'] . '<br />';
}
我还想显示“ autor”值重复的次数。例如:
John Smith (10)
Jack Sparrow (7)
如何获取这样的值?
答案 0 :(得分:1)
获取author
信息的方式相同:
echo $book['value_occurrence'];
在这种情况下,您可以使用
echo $book['autor'] . '(' . $book['value_occurrence'] . ')';