我自己设计了一些模拟数据但是都是可以按照表的顺序显示,不知道你的为什么不可以?
但是可以通过制定顺序的方式排序:select one ,two from (
select COMPNAMENAME as one,'COMPANY' as two from COMPANY where VALIDFLAG=1
union
select STUFFNAME as one,'STUFFINFO ' as two from STUFFINFO where VALIDFLAG=1 and TUFFID<>0
union
select DEPNAME as one,'DEPARTMENT ' as two from DEPARTMENT where VALIDFLAG=1 and DEPID<>0
)
order by two desc
;
但是可以通过制定顺序的方式排序:select one ,two from (
select COMPNAMENAME as one,'COMPANY' as two from COMPANY where VALIDFLAG=1
union
select STUFFNAME as one,'STUFFINFO ' as two from STUFFINFO where VALIDFLAG=1 and TUFFID<>0
union
select DEPNAME as one,'DEPARTMENT ' as two from DEPARTMENT where VALIDFLAG=1 and DEPID<>0
)
order by two desc
;
select STUFFNAME from STUFFINFO where VALIDFLAG=1 and STUFFID<>0 union all
select DEPNAME from DEPARTMENT where VALIDFLAG=1 and DEPID<>0
select COMPNAMENAME as one,'COMPANY' as two from COMPANY where VALIDFLAG=1
union
select STUFFNAME as one,'STUFFINFO ' as two from STUFFINFO where VALIDFLAG=1 and TUFFID<>0
union
select DEPNAME as one,'DEPARTMENT ' as two from DEPARTMENT where VALIDFLAG=1 and DEPID<>0
)
order by two desc
;