How Do I Write a Multiple Inner Join?
Posted on 2009-07-04
Hi, I know this type of question has been asked and answered many times, and I've looked through numerous threads, but everything I've tried hasn't worked for me. Obviously, I'm doing it wrong, but I haven't been able to figure it out, so I thought I'd ask it once again. I apologize in advance.
I have three tables that I need to join in my query, a comments table, a photos table, and a users table. I need to return a list of comments, the name of the user who made them, and the name of the photo that the comment was made on.
The comments table contains the user id, and the photo id. Here's the query I have right now, which gets the comment, and the photo title. I just need to add an inner join to get the user name as well:
$sql="Select * From CmtsSharedPhoto c INNER JOIN sharePhotoFiles p ON cmt_object_id = medID order by cmt_time desc LIMIT 100";
The user id in the comments table is "cmt_author_id", and in the users table (Profiles), the user id is "ID".
If you need anything else, just let me know! Thanks!!