Workings of Forum software

From: <mynameismisterbig_at_gmail.com>
Date: Mon, 22 Oct 2018 08:28:02 -0700 (PDT)
Message-ID: <b377e4e3-5df1-43be-b7d6-fabb770400b9_at_googlegroups.com>



[Quoted] ..So, I got around to wondering about how forum software works, cause I wanna make my own. In my "Posts" table, I have a "threadid" field (there's a separate "Threads" table containing just a primarykey (which is the above "threadid" field, and topic), the post itself, it's author and the date posted (including time). Now, the task at hand is to find all posts with a given threadid, and sort them ORDER BY date DESC, (ie. newest first), and then sort THAT table to get the thread with the newest post, first, among ALL threads. I'm a little confused as to how to accomplish this.

What's occurred to me:

First, we have to find all posts with a given threadid and sort them by date - is "GROUP BY threadid ORDER BY DATE DESC" the right way to accomplish this? How would the entire SELECT query go?

And then, from the above table, we have to get *the first line for each threadid* (ie. the newest post), and ORDER BY DATE DESC *amongst those* - I can't figure out how to get only the FIRST line of the first query, above. We have to do the first query, and then do a SELECT IN and then do what I just mentioned above, am I right?

[Quoted] [Quoted] Btw, I want to keep the date in dd/mm/yyyy format in the table - how would I do this? And I also want to keep the time - hour:min:sec format. Will ORDER BY DATE DESC sort it correctly in this case? Or do I have to do something special?

Thanks. Received on Mon Oct 22 2018 - 17:28:02 CEST

Original text of this message