Hello, I'm having trouble forming a MySQL query that performs the following action:
Select all threadIDs from the threads table ordering by the timestamp (in descending order) of the most recent post (largest timestamp) with threadID equal to the threadID of each thread. So basically I want to go through the threads and have MySQL check the database for let's say thread 0. It then checks all of the posts that have threadID of 0 and sorts thread0 based on the largest timestamp of the posts inside of thread0. Then it repeats this for thread1, thread2, etc and sorts them accordingly.
Is this even possible? It is to create the "bump-system" effect of the forum, where the most recently active thread is bumped to the top of the list continuously until the thread dies out, then it drops to the bottom. I used to use a different implementation where I stored a lastActivity timestamp in the threads table and updated it when a new post was submitted into the thread, but this query would make things a lot more efficient.
Thanks a lot! There are two tables relevant here: threads and posts. The posts have a threadID field that stores the ID of the thread it belongs to, and it also has a timestamp field. Threads has a field threadID that corresponds to the post's threadID.