这个sql语句怎么写:按照两个条件查询,其中一个优先。select * from table where 条件一 !important  OR 条件二即满足条件一的结果排在前面这个SQL语句怎么写呢?

解决方案 »

  1.   

    select * from table where 条件一
    union all
    select * from table where 条件二
      

  2.   

    SELECT * FROM TB WHERE A=1 
    union all
    SELECT * FROM TB WHERE  A=3or转成UNIOIN ALL还有要举例和数据问题
      

  3.   

    string sql="select * from table where 1=1";
    sql+=条件一?(条件二?"":""):"";
      

  4.   

    select * from 表
    order by case
    when 条件1 then 0
    when 条件2 then 1 end估计和这个问题差不多:
    http://blog.csdn.net/gdjlc/archive/2010/06/27/5697408.aspx