Photos: id, uid, date;
Friends: uid1, uid2, date, status;
I want show latest photos for friends of user. How do I do?
This will do it:
SELECT p.id
FROM Photos AS p, Friends AS f
WHERE p.uid = f.uid2 AND f.uid1 = ${userX.id}
ORDER BY p.date DESC
LIMIT 1;