如何在CodeIgniter中表示SQL“有计数(' *')”?

时间:2016-12-21 09:16:07

标签: php mysql codeigniter

此代码在MySQL中运行且没有错误:

SELECT
    name, email, COUNT(*)
FROM
    users
GROUP BY
    name, email
HAVING 
    COUNT(*) > 1

如何在CodeIgniter中重现此内容?我需要知道如何代表COUNT(*) > 1

例如:

function duplicate_m()
{
    $q=$this->db->select('*')->group_by(array("name","email"))->get("users"); 
    return $q->result();

}

1 个答案:

答案 0 :(得分:0)

这是代码

function duplicate_m()
    {
        $q=$this->db->select('count(*) as cnt')->group_by(array("name","email"))->having("cnt > 0", null, false)->get("users"); 
        return $q->result();

    }

我希望这会有所帮助