Jump to content

Inner join on 3 tables


jkewlo

Recommended Posts

Hey cant seem to figure this out!

 

I have users, following, and post all different tables It's kinda like Twitter

 

I have users that can Follow other users but I need to get the users post that he/she is following

 

Following Table

user_id

follower_id

 

Users Table

id

 

Post Table

id

user_id

 

I need to inner join the three tables so that user_id can get the followers post if you goto http://www.eve-lounge.com

I just need to get the post from the users someone is following.

Link to comment
Share on other sites

If you don't get answers to your question this is usually for one of these two reasons.

1. Noone knows the answer

2. Your question is not clear enough

 

Posting it again in other section is unlikely to help (and likely to annoy people)

 

Now to your question. You really should give us some example of a result you would like to get... that would help

 

How about this:

SELECT 
  p.id 
FROM 
  postTable AS p 
INNER JOIN
  followTable AS f
ON
(p.user_id = f.follower_id)
WHERE
f.user_id = ?

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.