I have a custom forum built and all is running well but I'm struggling with setting up one query. The relevant tables are: forum_threads forum_posts Posts go inside of threads and have the column `thread` to their parent thread. Both of these tables have the column `date`. How would I create a "Recent Threads" query that combines both of these tables. I would like the query to return the most recent threads while accounting for posts inside of them. Hopefully this is clear enough, thanks in advance.
I'm looking to combine those, the results should include newest made threads along with newest posts, but I will just display the thread where the post was made.
I'd suggest adding a column, 'last_updated' in the table forum_threads, and in this column put the date of the last post. So when you create the thread at first just have it put the same value for 'date' in for 'last_updated'. Then when a new post for the specific thread is made have it update the forum_threads table column 'last_updated' to the date the post was made. Then you can just query the DB and list the threads by 'last_updated', and use LIMIT to tell how many threads to display.