Find Duplicate records in table mysql :: PHP ci

0
838
$this->db->select('table_name.company_name,table_name.pincode');
 $this->db->select('IF(COUNT(table_name.company_name),COUNT(table_name.company_name),0) as countCompanyName');
 $this->db->select('IF(COUNT(table_name.pincode),COUNT(table_name.pincode),0) as countPincode');
 $this->db->from('table_name');
 $this->db->having('countCompanyName > 1');
 $this->db->having('countPincode > 1');
 $this->db->group_by(array("table_name.company_name", "table_name.pincode"));
 $records = $this->db->get()->result_array();

LEAVE A REPLY

Please enter your comment!
Please enter your name here