Wednesday, 7 August 2013

JOIN Query for Specific Table

JOIN Query for Specific Table

I have the following tables:
Login
IDUser (Int) username (Var) pass (Var)
Photos
IdPhoto (Int) title (Var) IdUser (Int)
Following
IdUser (Int) followingID (Int)
I am trying to create a query that fetches the 'photos' from the people
you are following.
So far, I have created a query that grabs the 'photos' from everyone
across the service:
$query = "SELECT IdPhoto, title, l.IdUser, username FROM photos p JOIN
following login l ON (l.IdUser = p.IdUser) WHERE following.followingID =
following.userID ORDER BY IdPhoto DESC LIMIT 50;
Any help would be appreciated.

No comments:

Post a Comment