Home  >  Article  >  Backend Development  >  mysql - thinkphp查询一个字段并查询该字段的每个值出现的次数

mysql - thinkphp查询一个字段并查询该字段的每个值出现的次数

WBOY
WBOYOriginal
2016-06-06 20:08:401386browse

感觉自己好笨啊。。。

回复内容:

感觉自己好笨啊。。。

<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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn