34,588
社区成员
发帖
与我相关
我的任务
分享
create table g1
(
f1 int,
f2 varchar(5)
)
insert into g1
select 1,'zzzz'
union all select 2,''
union all select 2,null
union all select 2,'bbbb'
select *
from g1
--我想查询所有不为null,而且不为空白字符串的记录
--我想问问下面两种方法,哪种效率高,为什么?
--方法1:
select *
from g1
where isnull(f2,'')<>''
--方法2:
select *
from g1
where f2 is not null and f2<>''