select a from table1 where(条件)
如果有记录显示查询出来的记录,如果没有记录显示“无”,如下所示有记录:                   无记录:
a                          a
----------                 ----------
a1                         无
a2
a3
...

解决方案 »

  1.   

    select a from table1 where(条件)----没是好明白你的意思select case when (条件) then a else '无' from table1  我理解的
      

  2.   

    select a from table1 where(条件)----不是好明白你的意思select case when (条件) then a else '无' end a from table1  --我理解的
      

  3.   

    if exists(select 1 from table1)
    select * from table1
    else
    select '无' from table1
      

  4.   

    if exists(select 1 from table1 where ........)楼上的需要加条件where
      

  5.   

    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