select * from tablename where a in (1,2)

解决方案 »

  1.   

    select top 1 * from tablename where a in (1,2) order by A
      

  2.   

    select * from tablename where A = 1
    or (A=2 and not exists(select 1 from tableName where A=1))
      

  3.   

    select * from tablename where a=(case when exists(select 1 from tablename where A=1) then 1 else 2 end)
      

  4.   

    select * 
    from tablename a join
         (  select min(A) as A 
            from tablename
            group by A
            where A in (1,2)
         ) b 
         on a.A=b.A
      

  5.   

    if(not EXISTS(select * from spt_server_info where 1=2)) select * from spt_server_info where 1=1 
    这样写行不行!?