一个或查询,先查找出关键字满足条件(再按时间等排序)排在最前,再找出标题满足条件的(按时间排序)次之...,总之满足关键字要求的总是排在满足标题的前面。高手赐教!!!

解决方案 »

  1.   

    select * from (
    select ......,'0' flag from table where 关键字...
    union
    select ......,'1' flag from table where 标题...)
    order by flag;
      

  2.   

    select * from (
    select ......,'0' flag from table where 关键字... order by time
    union
    select ......,'1' flag from table where 标题... order by time)
    order by flag;
      

  3.   

    select * from tab_name 
    where 关键字 = '关键字'
    or 标题 = '标题')
    order by decode(关键字,'关键字',1,2), time
      

  4.   

    hehe, 多敲了一个)
    select * from tab_name
    where 关键字 = '关键字'
    or 标题 = '标题'
    order by decode(关键字,'关键字',1,2), time
      

  5.   

    多谢大家搞定了,只试了一楼的就解决了。看来小弟的数据库知识还远远不够。还有就是4楼兄弟的order by decode(关键字,'关键字',1,2), time这句不是很明白,是什么意思,特别是:关键字,'关键字',1,2。 马上结贴。