I’m completely stumped on this, and the logic behind it isn’t correct so I’m turning to the experts once again.
Here are my tables:
| Table.Follow |
| OwnerID | UserID |
| Table.Users |
| ID | UserName |
| Table.Post |
| ID | OwnerID | Post | Date |
I’m trying to get the Post from the Users I’m following, including the User’s info. So the logic I came up with…
Follow.OwnerID = ME AND Follow.UserID = Users.ID = Post.OwnerID
But also, how would I include my own Postings that are on there?
Here is my SQL:
SELECT * FROM Table.Post
JOIN Table.Users ON Table.Post.OwnerID = Table.Users.ID
JOIN Table.Follow ON Table.Post.OwnerID = Table.Follow.UserID
AND Table.Follow.OwnerID = '$MyID'
ORDER BY Table.Post.Date DESC
But this doesn’t give me my postings as well, this only provides the postings of the users I’m following. The issue is I’m using the ID’s I’m getting from the Table.Follow, and obviously I can’t follow myself. So I did this but it doesn’t work:
SELECT * FROM Table.Post
JOIN Table.Users ON Table.Post.OwnerID = Table.Users.ID
JOIN Table.Follow ON Table.Post.OwnerID = Table.Follow.UserID
AND (Table.Follow.OwnerID = '$MyID' OR Table.Post.OwnerID = '$MyID')
ORDER BY Table.Post.Date DESC
Any suggestions?
1 Answer