wallaceoc80
Programmer
I have another SQL query that I'm having trouble with.
I have a board table and a messages table
board(boardID, title, date)
messages(messageID, title, author, body, board, thread, date_created)
The table keeps track of messages in a message board. The way I keep track to see whether a message is a thread starting message or a reply to a messages is through the thread column.
If the message is starting a new thread then the value 0 is inserted into the colum. If it is a reply to a certain thread then the messageID of the starting message.
I want to write a query that will return all threads that belong to one particular board (say boardID 1). All I want to return is the messageID of the original starting message of the thread, the author of the original starting message of the thread and the total number of replies for the thread!
How can I do this? Do I use a self-join for on the messageID column?
Please help!!
Thanks,
Wallace
I have a board table and a messages table
board(boardID, title, date)
messages(messageID, title, author, body, board, thread, date_created)
The table keeps track of messages in a message board. The way I keep track to see whether a message is a thread starting message or a reply to a messages is through the thread column.
If the message is starting a new thread then the value 0 is inserted into the colum. If it is a reply to a certain thread then the messageID of the starting message.
I want to write a query that will return all threads that belong to one particular board (say boardID 1). All I want to return is the messageID of the original starting message of the thread, the author of the original starting message of the thread and the total number of replies for the thread!
How can I do this? Do I use a self-join for on the messageID column?
Please help!!
Thanks,
Wallace