You are confused on the use of GROUP BY. If you have a query with only two fields and you use GROUP BY on both of them, you are telling the DBMS not to do anything with grouping. If you say "GROUP BY forumid" and leave it at that, you will only get one line per forumid. GROUP BY is used to specify how to generate summaries. If you had specified
GROUP BY forumid, postid DESC
You would have not needed to use the ORDER BY clause because MySQL automatically orders the columns used in a GROUP BY clause.
Originally posted by comart
thanks for your reply
but it want GROUP BY ForumID, then its PostID after that...
your SQL just return all mixed ForumID, PostID
thank you aus,
in fact I 've not tried your code yet when I replied you cause my lack of experience, sorry :-)
your code worked well and help me understand much about GroupBy and other things, thank you again, good luck to you ;-)