sql server - How should I have select unblocked comment on SQL -


how should have select unblocked comments

enter image description here

for example have these tables , records,is possible show list of comments 1 user wants see ?

something this: list of comments userid2(b) can see

result must be:

{ 2, "comment 3" & 2, "comment 4" & 4, "comment 6" } 

here wrong select:

select             comments.comment, comments.userid                 users  inner join     comments on users.userid = comments.userid  inner join     block on users.userid = block.blockerid , users.userid = block.blockedid             (block.blockerid <> 2)      , (block.blockedid <> 2)      , (users.userid = 2) 

also here link of sample db "testdb.bak":

click here download(file size:200kb)

thank helping me

i think you're looking this:

select a.userid, a.comment comments left join block b on a.userid = b.blockedid , b.blockerid = <your user here> b.blockerid null; 

Comments