select a from table1 where(条件)----没是好明白你的意思select case when (条件) then a else '无' from table1 我理解的
select a from table1 where(条件)----不是好明白你的意思select case when (条件) then a else '无' end a from table1 --我理解的
if exists(select 1 from table1) select * from table1 else select '无' from table1
if exists(select 1 from table1 where ........)楼上的需要加条件where
create table table1(a varchar(8)) insert table1 select 'a1' union all select 'a2' union all select 'a3' goif exists(select * from table1 where a='a1') select * from table1 where a='a1' else select top 1 '无' as a from table1 if exists(select * from table1 where a='a4') select * from table1 where a='a4' else select top 1 '无' as a from table1drop table table1
select * from table1
else
select '无' from table1
insert table1 select 'a1'
union all select 'a2'
union all select 'a3'
goif exists(select * from table1 where a='a1')
select * from table1 where a='a1'
else
select top 1 '无' as a from table1
if exists(select * from table1 where a='a4')
select * from table1 where a='a4'
else
select top 1 '无' as a from table1drop table table1