Hi, I'm reading thru a book and came across this piece of code: $verify = "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]"; I know it's comparing two tables and some fields, but I don't understand how it works. I would appreciate it if someone could translate it into English so that I can see what's going on.... Thanks, mvallar
You're going through the data in forum_posts and forum_topics and matching all the rows where the fields forum_posts.topic_id is equal to forum_topics.post_id and where the forum_posts.post_id is equal to the posted data.
Each topic can have a number of posts (one to many relationship), the way for the script to know which topic a post belongs to is by using IDs. Each topic has an ID, and each post has a database field corresponding to a topic ID. So then, in the query, you can select the post and the associated topic by finding one with matching IDs (comparing the post_id field in both tables)
turiel and krt - thanks guys! I appreciate the input. Your explanations have helped me understand this code. best regards, mikev