select * from ( select ......,'0' flag from table where 关键字... union select ......,'1' flag from table where 标题...) order by flag;
select * from ( select ......,'0' flag from table where 关键字... order by time union select ......,'1' flag from table where 标题... order by time) order by flag;
select * from tab_name where 关键字 = '关键字' or 标题 = '标题') order by decode(关键字,'关键字',1,2), time
hehe, 多敲了一个) select * from tab_name where 关键字 = '关键字' or 标题 = '标题' order by decode(关键字,'关键字',1,2), time
多谢大家搞定了,只试了一楼的就解决了。看来小弟的数据库知识还远远不够。还有就是4楼兄弟的order by decode(关键字,'关键字',1,2), time这句不是很明白,是什么意思,特别是:关键字,'关键字',1,2。 马上结贴。
select ......,'0' flag from table where 关键字...
union
select ......,'1' flag from table where 标题...)
order by flag;
select ......,'0' flag from table where 关键字... order by time
union
select ......,'1' flag from table where 标题... order by time)
order by flag;
where 关键字 = '关键字'
or 标题 = '标题')
order by decode(关键字,'关键字',1,2), time
select * from tab_name
where 关键字 = '关键字'
or 标题 = '标题'
order by decode(关键字,'关键字',1,2), time