Join Order By...?
Posted: Thu Jul 02, 2009 1:30 pm
Good evening all,
Ok, I'm making a forum for my site, and in order to count all stats, how many posts each thread has etc, I use a query like:
This works fine, however, I'd like to grab the subject of the last post from the join, and display it.
If the join was ordered by `ID` DESC then the last post would be in `LastPost`, however, I can't figure out how to order the join, or if that's even possible. I've searched all over google...
Any help would be much appreciated
Thanks,
Jack.
Ok, I'm making a forum for my site, and in order to count all stats, how many posts each thread has etc, I use a query like:
Code: Select all
SELECT F.*, COUNT(P.`ID`) AS `PostCount`, P.`Subject` AS `LastPost` /*<- not working!*/
FROM `Forum` F
INNER JOIN `Forum` P ON P.`Thread`=F.`ID`
WHERE F.`Type`='thread'
GROUP BY F.`ID`
ORDER BY `ID` DESCIf the join was ordered by `ID` DESC then the last post would be in `LastPost`, however, I can't figure out how to order the join, or if that's even possible. I've searched all over google...
Any help would be much appreciated
Thanks,
Jack.