Hi all,I've been working on a query that is working fine apart from I only want to retrieve one messageID (the latest MS.messageID)However, it's currently returning results for all the messageID for that TP.topicIDI've attached the SQL below:SELECT TP.topicTitle , TP.topicID , TP.topicSubTitle , TP.dateAdded , TP.views , TP.author , TP.important , TP.hottopic , TP.answered , TP.lastmemberdate , CG.categoryID , CG.categoryTitle , MB.nickname , MB.memberID , max(MS.messageID) as highest_messageID , count(MS.messageID) as numbReplies FROM ((( f_categories as CG LEFT JOIN f_topics as TP ON CG.categoryID = TP.categoryID )LEFT JOIN f_messages as MS ON TP.topicID = MS.topicID )LEFT JOIN f_members as MB ON TP.memberID = MB.memberID ) WHERE TP.active = '1' AND CG.categoryID = #URL.categoryID#GROUP BY TP.topicTitle , TP.topicID , TP.topicSubTitle , TP.dateAdded , TP.lastmemberdate , TP.views , TP.author , TP.important , TP.hottopic , TP.answered , CG.categoryID , CG.categoryTitle , MB.nickname , MB.memberID , MS.messageIDORDER BY TP.important DESC, TP.dateAdded DESC
Any ideas what I'm doing wrong.Thanks,Richard