不如说查询这样的语句
select a, b ,c  from aaa  where  d='c';返回为空没结果能不能显示
1 1 1 或者用其他表示 null null null 这样也行,就是不要没有结果...

解决方案 »

  1.   

    不明白这样可以吗select a, b ,c from aaa where 1=2
      

  2.   

    select a, b ,c from aaa where d='c'
    union all
    select 1,1,1 where not exists(select 1 from aaa where d='c')
      

  3.   

    树哥,这样是有问题的,select 没有FORM 不行吧
      

  4.   

    哥,这样可以的。没有FROM 也可以选出结果
      

  5.   

    测试了一下,没有FORM是没有问题,
    但是有数据存在的时候会多出1,1,1的一行数据
      

  6.   

    if not OBJECT_ID('aaa') is  null
    drop table aaa
    go
    CREATE table aaa (a char(10),b char(10),c char(10),d char(10))
    insert into aaa 
    select 'A','b','c','/' union all
    select 'A','c','c','/' union all
    select 'A','c','c','/' union all
    select 'A','c','c','/' 
    go 
    select a, b ,c from aaa where d='/'
    union all
    select '1','1','1' where not exists(select 1 from aaa where d='c')
    /*
    a         b         c
    A          b          c         
    A          c          c         
    A          c          c         
    A          c          c         
    1         1         1
    */
      

  7.   

    select *  from 表 where 条件
    if @@rowcount<=0
    begin
    select 1,1,1
    end
    --这样可以解决
      

  8.   

    条件不一样,所以会出现多一行,条件一样就不会出现select a, b ,c from aaa where d='/'
    union all
    select '1','1','1' where not exists(select 1 from aaa where d='/')