I have a messages table.
I want show people who send or recieve message with user named "Mean" and sort by read=no and id (desc). So the correct sorting should be;
1167--Cevatkar--Mean-no- ..................
1168--Çetinceviz--Mean-yes- ..............
1164--Mean--Mervee-yes- ......................
My sql query is
SELECT * from messages
where to = 'Mean' or from = 'Mean'
group by from,to
order by read='no',id DESC
limit 5
However, the query sorts the results incorrectly. When I echo the ids, I see that the query doesnt fetch the each group's (from or to = "Mean") last id. What is the correct way to do it ?