codeigniter distinct mysql query
codeigniter, mysql, php
Solution
Distinct will not always work. You should add -`>group_by("name_of_the_column_which_needs_to_be unique");`
Problem
whenever I use get_where in the model it gives me all database entries including duplications and when I use get only it only gives me the first entry. But I want all distinct entries. Can anyone help me please. Thanks a lot! Controler = site.php: ``` public function western_australia(){ $this->load->model("continents_get"); $data["results"] = $this->continents_get ->getMaincategories("western_australia"); $this->load->view("content_western_australia", $data); } ``` model = continents_get.php ``` function getMaincategories($western_australia){ $this->db->distinct(); $query = $this->db->get_where("p_maincategories", array("page" => $western_australia)); return $query->result(); } ``` view = content_western_australia.php ``` <?php foreach($results as $row){ $page = $row->page; $main_en = $row->main_en; echo $main_en; ?> ```