phpmysqlcodeigniteractiverecorddistinct

CodeIgniter script passing a column name to distinct() without not calling select() fails to remove duplicates


I want to select distinct values from a database table using CodeIgniter, but it returns duplicate values. Could you please check what is wrong with my code below?

$this->db->distinct('country');
$this->db->where('id', $id);
$query = $this->db->get('table_name');    

Solution

  • can try like this?

    $this->db->distinct();
    $this->db->select('country');