I am building a php/mysql forum, and it has two tables. The first is the master 'thread' table, and the second is the replies table, structures as such (omitting some columns that are not relevant to this question, such as 'title', 'body_text', etc).
thread_table Columns:
id (int, primary key)
user_id (int)
deleted (bool/tiny_int)
date_posted (datetime)
reply_table Columns:
id (int, primary key)
linked_to (int)
user_id (int)
deleted (bool/tiny_int)
date_posted (datetime)
I'm really stuck with my sql, I want to select all the 'threads', the latest 'reply' per thread where deleted does not equal 1, and also the total count of replies for each thread where deleted does not equal 1. And to top it off I also want to select the 'user_name' from my users table where the thread/reply 'user_id' is equal to the same id in the user table.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)