我如何确定我的结果集将排在a第一和b第二?这将帮助我解决棘手的订购问题。
a
b
这是我正在做的简化示例:
SELECT a FROM A LIMIT 1 UNION SELECT b FROM B LIMIT 1;
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