表名称: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'
)
但是此查询不会隐藏被阻止的用户的所有帖子
最佳答案
这个:
select * from user_post
where '{$userID}' not in (
select user_id from user_block
where status = '1'
)
如果 user_block
内 userid
的值为 1
,则将隐藏所有帖子。
如果您希望用户只看到他自己的帖子:
select * from user_post
where '{$userID}' not in (
select user_id from user_block
where status = '1'
)
and user_id = '{$userID}'
关于php - mysql查询隐藏被阻止的用户所有帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55098921/