照片:id,uid,date;
朋友:uid1,uid2,日期,状态;
我想为用户的朋友展示最新照片。我该怎么办?
答案 0 :(得分:2)
这样做:
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;
答案 1 :(得分:0)
SELECT id FROM photos WHERE uid IN(SELECT uid2 FROM friends WHERE uid1 = {$ uid1} ORDER BY date DESC LIMIT 1);
我认为UID1是用户而UID2是朋友,这将检索所有ID