日期:2014-05-18  浏览次数:20412 次

三个select联合查询,查询结果先以第一个表的字段排序,再以第二个表的字段排序,最后以第三个表的字段排序,怎么写啊
三个select联合查询,查询结果先以第一个表的字段排序,再以第二个表的字段排序,最后以第三个表的字段排序,怎么写啊

------解决方案--------------------
select * from 

select a.SubmitInfoRID ,1 as woyaomm
from t_event_submitInfo t 
left join t_event_submitOppose a on t.rid=a.SubmitInfoRID 
left join t_base_dept b on a.subopposerRID=b.rid 
union ALL 
select a.SubmitInfoRID ,2 as woyaomm
from t_event_submitInfo t 
left join t_event_submitOppose a on t.rid=a.SubmitInfoRID 
left join t_base_outdept c on a.subopposerRID=c.rid
union ALL 
select a.SubmitInfoRID ,3 as woyaomm
from t_event_submitInfo t 
left join t_event_submitOppose a on t.rid=a.SubmitInfoRID 
left join t_base_watchfix d on a.subopposerRID=d.rid
) as SubmitOpposer 
order by woyaomm ,SubmitInfoRID