【发布时间】:2019-08-06 05:37:21
【问题描述】:
我正在尝试编写查询以查找 Codegigniter 中的重复行,但它不起作用。 我的代码(模型)
$this->db->select('*');
$this->db->from('myTable sr');
$this->db->join('table2 s','sr.st_id=s.st_id');
if($conn!='')
{
$this->db->where($conn);
}
if($identity!='')
{
$where = "(s.student_id = '$identity' OR s.name LIKE '%$identity%')";
$this->db->where($where);
}
if($duplicate != '')
{
$this->db->having('COUNT("sr.st_id")>1');
}
if($limit_row!='')
{
$this->db->limit($limit_row,$starting);
}
$query = $this->db->get();
var_dump($this->db->last_query($query));exit;
return $query->result_array();
只返回第一条记录 重复数据在 myTable 中,我想找到这些重复项
【问题讨论】:
-
请提供数据。没有它,我们无法检查查询。
-
这个语句不清楚,有bug => $this->db->join('table2 s','sr.st_id=s.st_id'); rs','rs.resultState_id=sr.result_state');
-
我编辑了代码,目标是如何找到重复的。
标签: php mysql duplicates codeigniter-3