For a search feature for my forum, I'm trying to implement the ability to search only threads you have posted in.
So basically, I need to select threads, with at least one post that the user has made.
In my current query, P.`Author` is from a join consisting of all posts for the thread. I would have thought
Code: Select all
HAVING '$username' IN (P.`Author`)I'm not quite sure how to implement this...any help would be greatly appreciated.
Here's (a simplified version of) my full query:
Code: Select all
SELECT F.*, COUNT(P.`ID`) AS `PostCount`, MAX(P.`ID`) AS `LastPost`
FROM `Forum` F
INNER JOIN `Forum` P ON F.`ID` = P.`Thread` AND P.`Type`='post'
WHERE F.`Type`='thread'
GROUP BY F.`Author`
HAVING '$username' IN(P.`Author`) /*<- this is where I'm trying to select only threads with a post in by the user*/
ORDER BY F.`ID` ASCJack.