简体   繁体   中英

PHP/MySQL Latest photos friends

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM