当我运行以下脚本时,我在第一个查询中获得Null值,但在第二个查询中没有。如何在排除第一个uniqueidentifier值时仍然在第二个查询中包含Null值?
drop table program_field
create table program_field
(p uniqueidentifier
)
insert program_field values ('10C8BCA5-011C-48B9-BF46-03B88EBF5005'),
('16BD98AA-2323-4619-8BAF-0C19F90642FF'),
(Null)
select p from program_field
select p from program_field where p <> '10C8BCA5-011C-48B9-BF46-03B88EBF5005'
答案 0 :(得分:2)
select p from program_field where p <> '10C8BCA5-011C-48B9-BF46-03B88EBF5005' or p is null
答案 1 :(得分:2)
您需要IS NULL
中的IS NOT NULL
或where clause
表达式与null
值进行比较,例如:
p <> '10C8BCA5-011C-48B9-BF46-03B88EBF5005' or p is null
答案 2 :(得分:1)
你可以这样做..
select p from program_field where coalesce(p,'') <> '10C8BCA5-011C-48B9-BF46-03B88EBF5005'