想查询一个模型中 某个字段有多少条相同的记录,该怎么查 例如:查询表中 id 为 1的有多少条
用select() 查再 count(array) 应该是太浪费资源了吧
3 回答

慕丝7291255
TA贡献1859条经验 获得超6个赞
select *,count(*) from t_table group by id
tp5官方手册写法
Db::table('think_user')
->field('user_id,username,max(score)')
->group('user_id')
->select();
生成的SQL语句是:
SELECT user_id,username,max(score) FROM think_score GROUP BY user_id
- 3 回答
- 0 关注
- 563 浏览
添加回答
举报
0/150
提交
取消