此代码在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();
}
答案 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();
}
我希望这会有所帮助