【问题标题】:Get all user gd's of the users the person doesn't follow获取此人未关注的用户的所有用户 gd
【发布时间】:2020-10-18 22:52:35
【问题描述】:

我已经开始使用社交媒体应用程序,用户现在可以在其中关注和取消关注用户。但我需要一个查询来显示用户不关注的用户。我正在尽我所能,但找不到正确的解决方案。有人可以帮帮我吗?

我的两张桌子是这样的:

在 user_gd 的第二个表中将存储关注另一个用户的用户的 gd。

【问题讨论】:

  • 样本数据和期望的结果真的很有帮助。

标签: sql


【解决方案1】:

您的数据很难阅读。但想法基本上是not exists 或类似的东西:

select u.*
from users u
where not exists (select 1
                  from userFollows uf
                  where uf.followed_userid = u.userid and
                        uf.userid = ?
                 );

? 是您关心的用户的占位符。

【讨论】:

  • 感谢您的帮助!我想我明白了,我现在就试试。我会及时通知你。
猜你喜欢
  • 2020-03-28
  • 1970-01-01
  • 1970-01-01
  • 2015-05-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-10
相关资源
最近更新 更多