[eluser]oliur[/eluser]
It seems to me you do not need group by at all.
Remember, group by is only useful when you are applying some sort of aggregate function such as MIN,MAX,AVG etc.
If I understood you correctly, you want to display all messages by message_id ASC. And within that you want to display the ids in order of DESC correct?
In other words:
message_id = 1
id = 3
message_id = 1
id = 2
message_id = 1
id = 1
message_id = 2
id = 2
message_id = 2
id = 1
message_id = 3
id = 4
message_id = 3
id = 2
What you have to do is use order by on both of these columns.
So, your sql statement would look like
Code:
SELECT * FROM table_name ORDER BY message_id ASC, order_id DESC
In active record it may look something like this
Code:
$this->db->order_by(‘message_id’, ‘ASC’);
$this->db->group_by(‘id’,DESC);