出现这个错误的语句是酱紫的
select xxx from aaa order by xxx union all select yyy from bbb order by yyy
错误原因居然是,如果同时用了union all 和 order by,union all的子句要加上括号。
所以下面的写法就不会报错了。
(select xxx from aaa order by xxx) union all (select yyy from bbb order by yyy)