I was executing this query
select CardId, CardHeader from [Card]
where CardId not in (select CardId from RoleMap where RoleId = 2)
the output of (select CardId from RoleMap where RoleId = 2)
is null
and the output is 0 rows affected
You can try this using left join
select CardId, CardHeader from [Card] a left join RoleMap b on a.CardId =b.CardId
and RoleId = 2
where b.cardid is not null
Try this:
SELECT CardId, CardHeader
FROM [Card]
WHERE CardId NOT IN (SELECT ISNULL(CardId, 0) from RoleMap WHERE RoleId = 2)
use not exists
select t.* from [Card] t
where not exists (select 1 from RoleMap t1 where RoleId = 2
and t1.CardId=t.CardId)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.