Help with mySQL query
Posted: Fri Jul 25, 2003 7:24 am
I have built a simple forum using php and mySQL -
I have a boards table, a threads table, and a posts table to store the various parts of the forum. Each post/thread/board has an ID number - an autoincremented value used as primary key, and each post has a parentthreadID, each thread has a parentboardID - these are foreign keys to link up the various posts/threads etc.
In addition each board/thread has a name.
My question is, is there a query I can issue in mySQL involving joins or something else that will allow me to return the boardID, board_name, threadID, thread_name and perhaps other fields for a given postID?
Eg:
postID=30, parentthreadID for that post = 5, so look up thread no5, find out parentboardID, find name etc.....
It is the fact that three tables (at least) are involved that is confusing me
I have a boards table, a threads table, and a posts table to store the various parts of the forum. Each post/thread/board has an ID number - an autoincremented value used as primary key, and each post has a parentthreadID, each thread has a parentboardID - these are foreign keys to link up the various posts/threads etc.
In addition each board/thread has a name.
My question is, is there a query I can issue in mySQL involving joins or something else that will allow me to return the boardID, board_name, threadID, thread_name and perhaps other fields for a given postID?
Eg:
postID=30, parentthreadID for that post = 5, so look up thread no5, find out parentboardID, find name etc.....
It is the fact that three tables (at least) are involved that is confusing me