获取用户自己喜欢的帖子列表的查询是什么?

发布于 2024-11-12 02:07:20 字数 417 浏览 3 评论 0原文

是的,我知道用户“喜欢”自己的帖子是不寻常的,但这就是我正在寻找的。我还知道您无法按用户查询类似的表来获取他们喜欢的所有内容,但这不是我想要的。我只想要他们喜欢的自己的帖子(以及后来的照片)。

我的 SQL 技能显然已经变得生疏了——根据我发现的例子来玩弄语句:

SELECT source_id,message,created_time FROM stream WHERE source_id=me()

SELECT actor_id, post_id, message FROM stream WHERE uid IN (SELECT uid2 FROM like WHERE uid1=me())

想我想要做的事情要么微不足道,要么目前不可能。我希望是前者。

Yes, I know that it's unusual for a user to "like" their own posts but that's what I'm looking for. I also know that you can't query the like table by user to get everything they've liked but that's not what I'm after. I just want their own posts (and later, photos) that they've liked.

I've clearly gotten pathetically rusty in my SQL skills--playing around with statements based off of the examples I've found:

SELECT source_id,message,created_time FROM stream WHERE source_id=me()

and

SELECT actor_id, post_id, message FROM stream WHERE uid IN (SELECT uid2 FROM like WHERE uid1=me())

I imagine what I want is either trivial to do or currently impossible. I expect the former.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只怪假的太真实 2024-11-19 02:07:20

要获取用户喜欢的帖子 ID,可能类似于:

SELECT post_id 
FROM like 
WHERE object_id in (SELECT source_id FROM stream WHERE source_id=me())
AND user_id = me()

您可以将其扩展为也包括照片 ID。您可以使用类似的 post_id 字段将其嵌套到另一个深度以获取更多帖子信息。

To get the post ids that the user likes, it would be something like:

SELECT post_id 
FROM like 
WHERE object_id in (SELECT source_id FROM stream WHERE source_id=me())
AND user_id = me()

You could expand this to also include photo ids. And you could nest it another level deep to get more post info by using the like's post_id field.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文