php - MySQL Query adding another condition -


here query:

select photos.* photos inner join follows on photos.userid=follows.followingid follows.followerid = $myid order photos.id desc limit 10 

how add condition correctly can check photos user's id (using $myid variable)?

update: added conditional in syntax provided in answer, shows images users you're following not own photos though.

update 2: table structures:

table: photos

table: follows

from question difficult gather how tables set up, may you're looking for:

select photos.* photos left outer join follows on photos.userid=follows.followingid follows.followerid = $myid or photos.userid = $myid order photos.id desc limit 10 

edit: see you're trying do, need left outer join include every result photos table, should work.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -