gpt4 book ai didi

mysql - 连接事件列表中的三个表

转载 作者:行者123 更新时间:2023-11-29 22:21:10 24 4
gpt4 key购买 nike

我一直在研究这个 sql 查询,但无法理解它。我正在尝试从 users_activity 获取与 users_activityusers_followers 中的 user_id 相关的所有事件。如果 user1 关注其他 10 个用户,我希望获得与这 10 个用户相关的 users_activity 中的所有事件,在表 users_followers 中的时间戳 follower_since_timestamp 和 now() 之间>.

select
u1.user_name as `user_name being followed`,
u2.user_name as `follower_name that followes`,
ua.*
from users u1
join users_followers uf on uf.user_id=u1.user_id
join users u2 on u2.user_id = uf.follower_id
join user_activity ua on ua.user_id = u2.user_id
where u1.user_name='demo'
order by ua.activity_timestamp

这是我到目前为止所拥有的,但它获取“向后”。通过此查询,我获得了演示之后的所有事件。

最佳答案

This is what i have so far, but it fetches "backwards".

然后颠倒顺序?

order by ua.activity_timestamp DESC

将最新的放在第一位

关于mysql - 连接事件列表中的三个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30697632/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com