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

WBOY
Release: 2016-06-06 20:08:40
Original
1387 people have browsed it

感觉自己好笨啊。。。

回复内容:

感觉自己好笨啊。。。

<code>M($table)->field('field,count(field)')->group('field')->select()</code>
Copy after login

不要气馁
多熟悉下SQL就行了,和thinkPHP无关

<code>select field,count(field) from table</code>
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template