php - JOIN Query for Specific Table -


i have following tables:

login

iduser (int) username (var) pass (var)

photos

idphoto (int) title (var) iduser (int)

following

iduser (int) followingid (int)

i trying create query fetches 'photos' people following.

so far, have created query grabs 'photos' across service:

$query = "select idphoto, title, l.iduser, username photos p join following login l on (l.iduser = p.iduser) following.followingid = following.userid order idphoto desc limit 50; 

any appreciated.

select p.*, l.iduser, l.username  following f  left join login l on f.followingid = l.iduser  left join photos p on p.iduser = l.iduser  f.iduser = 1  limit 50 

this should fetch photos of people followed user id = 1 in example.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -