1

I am trying to get filters for the portfolio items listed in the database. As one filter can contain more than one portfolio item, the record duplicates the filters entry in the database.

My Code:

    $this->db->distinct();
    $this->db->select('filter_id, portfolio_id');
    $this->db->where('user_id', $user);
    $this->db->join('user_portfolio_filters', 'user_portfolio_filters.id =   user_portfolio_relationship.filter_id');
    return $this->db->get('user_portfolio_relationship')->result_array();

The filters return fine without the top two lines, however they repeat themselves, how can I only return the filters which have a unique 'filter_id'?

Thank you!

4

1 回答 1

0

Check this answer https://stackoverflow.com/a/7250654/1666071

I think what you want is GROUP BY filter_id, not DISTINCT

于 2013-03-30T23:06:19.997 回答