你到底是需要NULL还是不需要NULL?select top 1 * from news where npic is null and type=1 and look=1 order by ndate desc
create table test(name varchar(10)) insert test select 'a' union all select null union all select 'b' goselect * from testname ---------- a NULL b(所影响的行数为 3 行)select * from test where name is not null;name ---------- a b(所影响的行数为 2 行)
npic是保存图片路径的,我要把有路径的搜索出来,空的就不搜了
--try: select top 1 * from news where isnull(npic,N'')<>N'' and type=1 and look=1 order by ndate desc
create table test(name varchar(10))
insert test select 'a' union all
select null union all
select 'b'
goselect * from testname
----------
a
NULL
b(所影响的行数为 3 行)select * from test where name is not null;name
----------
a
b(所影响的行数为 2 行)
select top 1 * from news where isnull(npic,N'')<>N'' and type=1 and look=1 order by ndate desc