表名:user_post
id user_id post
1 2 hi ths is aaaaa
2 3 hi ths is yyyyyy
表名:user_block
id post_id user_id block_id status
1 1 2 4 1
请告诉我被屏蔽的用户中的选择查询,所有帖子都应隐藏,我的查询是:
SELECT * FROM `user_block`
WHERE `id` NOT IN (
SELECT `post_id` FROM `user_block`
WHERE `user_id` = '{$userID}'
AND `status` = '1'
)
但是此查询不会隐藏被阻止的用户的所有帖子
答案 0 :(得分:0)
尝试一下
SELECT * FROM user_post LEFT OUTER JOIN user_block
ON user_post.user_id = user_block.user_id
WHERE user_block.user_id IS null
非常有用的帖子。加入视觉解释的here