mysql查询隐藏被阻止的用户的所有帖子 [英] mysql query to hide blocked user all posts
本文介绍了mysql查询隐藏被阻止的用户的所有帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
表名:user_post
Table Name: user_post
id user_id post
1 2 hi ths is aaaaa
2 3 hi ths is yyyyyy
表名称:user_block
Table Name: user_block
id post_id user_id block_id status
1 1 2 4 1
请告诉我被屏蔽的用户中的选择查询,所有帖子都应隐藏,我的查询是:
Please tell me the select query in blocked user all posts should be hide my query is:
SELECT * FROM `user_block`
WHERE `id` NOT IN (
SELECT `post_id` FROM `user_block`
WHERE `user_id` = '{$userID}'
AND `status` = '1'
)
但是此查询不会隐藏被阻止的用户的所有帖子
But this query doesnot hide blocked user all posts
推荐答案
此:
select * from user_post
where '{$userID}' not in (
select user_id from user_block
where status = '1'
)
如果userid
在user_block
中具有值1
,则
将隐藏所有帖子.
如果您只希望用户看到自己的帖子,则:
will hide all posts if userid
has the value 1
inside user_block
.
If you want the user to see only his own posts:
select * from user_post
where '{$userID}' not in (
select user_id from user_block
where status = '1'
)
and user_id = '{$userID}'
这篇关于mysql查询隐藏被阻止的用户的所有帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文