用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3040|回复: 2
收起左侧

[HELP] GROUP BY + COUNT怎么写

[复制链接]
发表于 2012-9-6 16:28:35 | 显示全部楼层 |阅读模式
select count(id) as nums,name from table where id = 12 group by name;

用这样的语法$this->db->where();CI中上面的sql语句怎么写。
发表于 2012-9-6 18:58:11 | 显示全部楼层
$this->db->select('count(id) as nums, name')->from('table')->where('id', 2)->group_by('name')->get()->row_array();
好好看手册
 楼主| 发表于 2012-9-7 09:54:59 | 显示全部楼层

本版积分规则