1.select * from posts where post_id in(select post_id from views where user_id<>123) or select * from posts p join views v on p.post_id=v.post_id and v.user_id<>123 2.select p.*,CASE when isnull(v.viewid,0)=0 then 0 else 1 end as viewstatus from posts p left join views v on p.post_id=v.post_id
source share