I am building a custom forum application with CodeIgniter. I have 4 primary tables: parents(categories), children(boards), threads, and messages(thread replies). What I would like to do is display the information of the latest post from a certain board... this will be on the index page of the forums. Here's what my tables look like. I won't list the category table since we won't be using that one for this feature.
| Table: Children ---| |--------------------| | child_id (int, 15) | |--------------------| | title (varchar, 65 | |--------------------|
| Table: threads ----| |--------------------| | thread_id (int, 15)| |--------------------| | first_msg_id(int, 15) |--------------------| | author_id(int, 15) | |--------------------| | title(varchar, 65) | |--------------------|
| Table: messages ---| |--------------------| | message_id(int, 15)| |--------------------| | thread_id(int, 15) | |--------------------| | author_id(int, 15) | |--------------------|
I was wondering if you guys could give me some ideas of how to use joins to do this? I have no idea where to start, else I would have given you some code... lol. Thanks for your time.
So I figured I would at least make an attempt at this, but I got as far as SELECT, and then had no idea about the left joins. Here's what I have so far...
$query = " SELECT m.message_id AS m_id, m.author_id, m.thread_id AS mt_id t.thread_id AS t_id, t.child_id AS tc_id FROM forum_messages AS m WHERE t.child_id = ".$board_id." LEFT JOIN "
The "Children" table
The threads table
The messages table