Using SQL to get the Last Reply on a Post
        Posted  
        
            by Anraiki
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Anraiki
        
        
        
        Published on 2010-03-24T07:22:32Z
        Indexed on 
            2010/03/24
            7:33 UTC
        
        
        Read the original article
        Hit count: 303
        
I am trying to replicate a forum function by getting the last reply of a post.
For clarity, see PHPBB: there are four columns, and the last column is what I like to replicate.
I have my tables created as such:
- discussion_id (primary key)
- user_id
- parent_id
- comment
- status
- pubdate
I was thinking of creating a Link Table that would update for each time the post is replied to.
The link table would be as follow:
- discussion_id (primary key)
- last_user_id
- last_user_update
However, I am hoping that theres a advance query to achieve this method. That is, grabbing each Parent Discussion, and finding the last reply in each of those Parent Discussions.
Am I right that there is such a query?
© Stack Overflow or respective owner