我正在尝试从最近的搜索表中仅检索唯一值。
public function get5RecentSearch()
{
$this->db->select('recent_search.*, category.category_name, category_two.cat_name,');
$this->db->from('recent_search');
$this->db->order_by("date", "desc");
$this->db->join('category', 'category.category_id = recent_search.category_one', 'left');
$this->db->join('category_two', 'category_two.cat_id = recent_search.category_two', 'left');
$this->db->limit(5);
$query = $this->db->get()->result_array();
return $query;
}
我已经尝试使用$this->db->distinct();
,但是没有用。我想念什么?
public function get5RecentSearch()
{
$this->db->select('recent_search.*, category.category_name, category_two.cat_name,');
$this->db->from('recent_search');
$this->db->order_by("date", "desc");
$this->db->join('category', 'category.category_id = recent_search.category_one', 'left');
$this->db->join('category_two', 'category_two.cat_id = recent_search.category_two', 'left');
$this->db->limit(5);
$this->db->distinct();
$query = $this->db->get()->result_array();
return $query;
}