---- How to group by one field and order by another?
MichaelBluejay - 11:45 am on Oct 21, 2012 (gmt 0)
Thanks again for the help. I left something out of my initial post to keep it simple, but I guess I should be more specific: I also need to pull only posts where the poster's very first post to the whole forum was made more than 24 hours ago. This ensures that I don't pull any spam posts which I haven't yet reviewed. So, the AND isn't actually completely useless. Here's my actual code, which uses a Perl variable for the time:
SELECT topic_id,posted,poster,message FROM posts temp1 WHERE posted=(SELECT MAX(temp2.posted) FROM posts temp2 WHERE temp1.topic_id = temp2.topic_id) AND poster in (SELECT poster FROM posts WHERE posted < $twentyFourHoursAgo) ORDER BY posted DESC LIMIT 20
With that in mind, does my query look okay to you now?