SELECT col FROM ( SELECT a col, 0 ordinal FROM A LIMIT 1 UNION ALL SELECT b, 1 FROM B LIMIT 1 ) t ORDER BY ordinal
我不认为订单是保证的,至少不是所有DBMS.
我过去为控制UNION中的顺序所做的是:
(SELECT a, 0 AS Foo FROM A LIMIT 1) UNION (SELECT b, 1 AS Foo FROM B LIMIT 1) ORDER BY Foo