以下Query的实际结果为NULL
select semid from programvariantterm where programvariantid = 240
但是当我尝试以下语句时,它会给出0行:
declare @semid int
set @semid = -1
select semid from programvariantterm
where programvariantid = 240 and semid = nullif(@semid,-1)
答案 0 :(得分:2)
我认为你有点混淆NULLIF
和ISNULL
。
您的陈述适用于以下ISNULL
:
where programvariantid = 240 and @semid = ISNULL(semid,-1)