当字符串为空时,在when 使用 is null来判断。
当字符串不为空时,在when 使用 is not null来判断。
例如:
create table test
(
stuno number(10) primary key,
stuname varchar2(50)
)
insert into test(stuno) values(10)
insert into test(stuno,stuname) values(11,' ')
select * from test where stuname is null才会取到所有值。
而select * from test where stuname=''不行。
本文介绍了在SQL中如何正确处理空字符串与NULL值的区别。通过示例说明了当需要判断字段是否为空字符串时,应使用IS NULL而非直接比较空字符串。这对于避免因数据质量问题导致查询结果不准确非常重要。
1570

被折叠的 条评论
为什么被折叠?



