fans913 发表于 2012-9-6 16:28:35

GROUP BY + COUNT怎么写

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();
好好看手册

fans913 发表于 2012-9-7 09:54:59

{:1_1:}
页: [1]
查看完整版本: GROUP BY + COUNT怎么写