The query below is returning that 3 results are available, but it is only returning one entry id.
How can I have the three entry_id's returned?
$this->EE->db->select('entry_id, count(portfolio_number) AS results');
$this->EE->db->from('submissions');
$this->EE->db->where('type_id', '1');
$this->EE->db->where('member_group', $member_group);
$this->EE->db->group_by('portfolio_number');
$this->EE->db->having('results = 3');
$query = $this->EE->db->get();
$submissions = $query->result_array();
print_r($submissions);
EDIT:
I have a table columns entry_id
, member_group
, type_id
and portfolio_number
.
The portfolio_number column will have a number between 1 and 7.
I need to query the database for 3 rows that have the same portfolio_number (as well as matching type and member_id) and return the entry_id for each of those three rows.
There must be 3 results, else I don't want to show them.
Your
$this->EE->db->group_by('portfolio_number');
is causing a single row with aggregated data to be returned.If you want all the ids to be returned as well, you can try adding
and then splitting the
entry_ids
field in PHP:Edit: I put in the second argument for the select query to prevent backticks being placed around the custom select query.
Can you please replace this code
I think it will return 3 rows of different entry_id
You can handle it like this