So I have this messages database between members in my CMS. I wanted to change the listing to show people instead of specific messages. Call it "threads" but each thread in the "my messages" page is a member that you've had a conversation with, right?
So, I obviously do this with something like this:
select id, msgfrom, headline from member.msg where msgto = $myid
group by msgfrom order by date desc
Right, but the problem with the above is that it shows the headline of the FIRST message from each "msgfrom". So the ordering by date is applied to the date of that first message. I.e. I want the entire row returned that represents the group to obey a specific ordering.
This would be relevant if I was to fetch all texts from a database and group them by category and thus show the last text from each category. All in one query.
To make matters worse, I would also want to fetch message "threads" where the other party hasn't yet responded (so there is no msgto = $myid yet, but rather a msgfrom = $myid) and the grouping should then be on "msgto" instead of "msgfrom"
So, any ideas?