PDA

View Full Version : How to join the 3 table?


uncleroxk
12-02-2008, 03:16 PM
Hi, to keep things simple I have 3 table..

user
id, username

blog
id, blog_post, user_id

blog_comment
id, blog_id

With blog_id in the blog_comment, i wan to retrieve the username, how do i do it?.. (I need the query string)

Thanks

Fumigator
12-02-2008, 04:46 PM
You reall only need to join the blog and user tables, assuming blog_id in the comments table is the primary key of the blog table.


SELECT user.username
FROM user
JOIN blog
ON user.id = blog.user_id
WHERE blog.id = '123412341234'