Home > Article > Backend Development > mysql - thinkphp查询一个字段并查询该字段的每个值出现的次数
感觉自己好笨啊。。。
感觉自己好笨啊。。。
<code>M($table)->field('field,count(field)')->group('field')->select()</code>
不要气馁
多熟悉下SQL就行了,和thinkPHP无关
<code>select field,count(field) from table</code>
select field,count(field) as ct from (select field from field) as tb group by field order by field;不知对否,自行测试
select field, count(field) from table group by field;
SQL GROUP BY