codeigniter活动记录语法

时间:2014-02-04 09:09:57

标签: php codeigniter activerecord

你好我有codeigniter活动记录代码

$this->db->select('concat(users.firstname, users.lastname) as name, users.id as user_id, count(1) as failed_s_count ,group_concat(choices_history.cou_name) as failed_ss');
$this->db->from('choices_history');
$this->db->join('users','users.id = choices_history.user_id');
$this->db->where('choices_history.status',3);
$this->db->group_by('choices_history.user_id');
$this->db->having('count(1) >= 3');

但是这给了我语法错误

FROM CONCAT(`u`.firstname, ' ' , `u`.lastname) as `name`, 
    `u`.id as `user_id`, 
    COUNT(1) as `failed_s_count`,
    GROUP_CONCAT(`ch`.cou_name) as `failed_ss`
FROM `choices_history` as `ch`
INNER JOIN `users` as `u` 
    ON `u`.id = `ch`.user_id
WHERE `ch`.status = 3
GROUP BY `ch`.user_id 
HAVING COUNT(1) >= 3

这是原始查询。

什么是问题?

0 个答案:

没有答案