I have a query that takes a friends list (a table of pairs of friends where each pair is listed twice, so a pair of friends A and B show up as A,B and B,A) and gets all the friends of a certain user, then gets the information for each of the friends from my userprofiles table. This all works great with the following query:
$query_friends_total = "SELECT up.email, up.first_name, up.last_name, up.id
FROM userprofiles up
LEFT JOIN friendslist f ON f.user = $userid
WHERE up.id = f.friend";
The problem is that I also need to get a variable from one other table. I need to get the image_id from my pictureprofile table where (with pictureprofile pp) pp.user_id = f.friend and pp.thumbnail != 0.
I tried to do it without an extra left join but failed. Does anyone know how to do this?