我应该如何选择未阻止的评论
例如,我们有这些表和记录,是否可以显示一个用户想要查看的评论列表?
这样的事情:userId2(B)可以看到的评论列表
结果必须是:
{ 2, "Comment 3" & 2, "Comment 4" & 4, "Comment 6" }
这是我错误的选择:
SELECT
Comments.Comment, Comments.UserId
FROM
Users
INNER JOIN
Comments ON Users.UserId = Comments.UserId
INNER JOIN
Block ON Users.UserId = Block.BlockerId AND Users.UserId = Block.BlockedId
WHERE
(Block.BlockerId <> 2)
AND (Block.BlockedId <> 2)
AND (Users.UserId = 2)
此处还有我的示例数据库&#34; testDB.bak&#34;的链接:
Click here to download(File size:200KB)
感谢您帮助我
答案 0 :(得分:0)
如果我理解规则,这似乎应该有效:
SELECT * FROM Comments WHERE UserId NOT IN (SELECT BlockedId FROM Block WHERE BlockerId=2)
答案 1 :(得分:0)
我认为你正在寻找这样的东西:
func updatePickValue(heroes: [Hero], withValue: Int, forSynergy: String) {
let filteredResults = heroes.filter({$0.synergy.contains(forSynergy)})
for hero in filteredResults {
hero.pickValue = withValue
}
}