Search code examples
phpmysqlcodeigniter-3

Is there a way to print record without duplicate from a table?


I have a table that have many records and others are duplicated. I want to print all the records out but I don't want the duplicated to echo more than once.

I have a tried to add break when a record is detected to be duplicate but the iteration stopped their immediately.

This is the sql statement.

$query = $this->db->query(select * 
from mytable 
where status = '1' and cityname= 'abuja' and age= '27' 
order by id ASC);

foreach ($query->result_array() as $rowx){ 

echo $rowx['xxx'];

}


Solution

  • Try to Use DISTINCT Keyword, It will resolve your query.