Table Name: user_post
id user_id post
1 2 hi ths is aaaaa
2 3 hi ths is yyyyyy
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
解决方案
This:
select * from user_post
where '{$userID}' not in (
select user_id from user_block
where status = '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}'