chibineku Posted August 3, 2009 Share Posted August 3, 2009 I am a little baffled by this query: $verify_sql = "SELECT ft.topic_id, ft.topic_title FROM forum_posts AS fp LEFT JOIN forum_topics AS ft ON fp.topic_id = ft.topic_id WHERE fp.post_id = '".$_GET["post_id"]."'"; Obviously I have two tables, one called forum_topics and one call forum_posts, and there are some PHP elements, but the workings of the query are not explained in the book from which this example comes. I understand how everything else works, though, but the author does not explain this query, merely calling it complicated looking... Link to comment Share on other sites More sharing options...
justsomeguy Posted August 3, 2009 Share Posted August 3, 2009 It's doing a left join, so it's going to select the records from the forum_posts table and, if there are matching records from the forum_topics table for that post, it will also select those matching records. It's not returning anything from the forum_posts table, but it looks like it's trying to look up a certain post ID, so it's getting information about the topic for that post. Look up SQL joins if you want more information about how they work. Link to comment Share on other sites More sharing options...
chibineku Posted August 3, 2009 Author Share Posted August 3, 2009 I understand basic joins, though I can never remember them without looking them up, but it's the fp / ft business. I guess one stands for forum_topics and the other for forum_posts, but I wasn't aware it was necesary to create new names like that. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 3, 2009 Share Posted August 3, 2009 It's not necessary, it's just an alias if you don't want to keep typing the full name. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.