我有这张桌子
create table [test]
(
id int identity(1,1) primary key,
name nvarchar(50),
clientid int null -- Can be null
)
我有这个存储过程:
create procedure sp_GetValue
(@client int = null)
begin
select *
from test
where clientid = @client
end
问题是,当client等于null时,即使我的记录具有null clientid,它也不会返回任何内容
使用布尔逻辑:
where (@client is null and clientid is null) or clientid = @client
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句