PHP/MySQL 最新照片啦
照片:id、uid、日期;
好友:uid1、uid2、日期、状态;
我想向用户的朋友展示最新的照片。我该怎么办?
Photos: id, uid, date;
Friends: uid1, uid2, date, status;
I want show latest photos for friends of user. How do I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这将做到这一点:
This will do it:
SELECT id FROM photos WHERE uid IN (SELECT uid2 FROM Friends WHERE uid1 = {$uid1} ORDER BY date DESC LIMIT 1);
我假设 UID1 是用户,UID2 是朋友,这将检索所有 ID
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