Combine SQL statement
Posted
by ninumedia
on Stack Overflow
See other posts from Stack Overflow
or by ninumedia
Published on 2010-05-24T20:31:11Z
Indexed on
2010/05/24
20:41 UTC
Read the original article
Hit count: 253
I have 3 tables (follows, postings, users)
follows has 2 fields -> profile_id , following_id
postings has 3 fields -> post_id, profile_id, content
users has 3 fields -> profile_id, first_name, last_name
I have a follows.profile_id value of 1 that I want to match against.
When I run the SQL statement below I get the 1st step in obtaining the correct data. However, I now want to match the postings.profile_id of this resulting set against the users table so each of the names (first and last name) are displayed as well for all the listed postings.
Thank you for your help! :)
Ex:
SELECT *
FROM follows
JOIN postings ON follows.following_id = postings.profile_id
WHERE follows.profile_id = 1
© Stack Overflow or respective owner