I am having a hard time creating a mySQL join statement.
The issue is that it seems to return the correct results, but it returns duplicates.
$result= mysql_query("SELECT Photos.Filename, Photos.Filetype
FROM Photos, PhotoUserTags
WHERE PhotoUserTags.User_ID IN ($friendlist) && PhotoUserTags.Photo_ID = Photos.Photo_ID && Photos.Event_ID = $eid");
I am new to these statements, any help or guidance is greatly appreciated.
For one, the logical and in mysql is not
&&butAND, like this:You should also use the newer join syntax like this:
Note the join expression (I used inner join, assuming a matching record needs to exist in both tables) – it makes your where cleaner and easier to read.