【发布时间】:2018-01-21 20:01:19
【问题描述】:
在这里完成 SQL Server 菜鸟。我不知道如何去寻找答案,因为我大多不知道从什么开始搜索。
我的 SQL Server 数据库中有 BLOG 表,用于存储类似的博客文章
ID Title DatePosted
-----------------------------------------------
1 Why Batman is Greater than Sup... 07/15/2017
2 10 Reasons Superman is the wor... 08/02/2017
3 Sick of Metropolis? Move to Go... 08/03/2017
我有另一个关系表存储用户喜欢的博客,即,
UserID PostID DateLiked
-------------------------------
232413 2 08/03/2017
232413 1 07/30/2017
234285 2 08/03/2017
现在我想做的是在我的BLOG 表上调用一个简单的SELECT *,但将UserID 作为参数传递给该查询以确定该用户是否喜欢该博客,所以我的结果集看起来像这样。
给定用户 ID:232413
ID Title DatePosted IsLiked
--------------------------------------------------------
1 Why Batman is Greater than Sup... 07/15/2017 1
2 10 Reasons Superman is the wor... 08/02/2017 1
3 Sick of Metropolis? Move to Go... 08/03/2017 0
这在 SQL Server/数据库中可行吗?非常感谢任何提示或有用的阅读!
【问题讨论】:
-
为什么
Sick of Metropolis? Move to...有IsLiked = 1?喜欢的帖子 ID 是 1 和 2。 -
啊,谢谢@rcs
标签: sql-server database