开发者

PHP/MySQL Latest photos friends

开发者 https://www.devze.com 2023-02-19 14:29 出处:网络
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:

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;


SELECT id FROM photos WHERE uid IN (SELECT uid2 FROM friends WHERE uid1 = {$uid1} ORDER BY date DESC LIMIT 1);

I supposed that UID1 is the User and UID2 is the friend, this will retrieve all the IDs

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号