表1 有(15,16,17.20)表2 有(19,20,21)我的结果表应该是 表3 (15,16,17,20,19,20,21)。
答案 0 :(得分:4)
使用UNION ALL
,这将保留重复记录:
SELECT col
FROM Table1
UNION ALL
SELECT col
FROM Table2
如果你想要你指定的确切顺序,那么这个子查询将派上用场:
SELECT t.col
FROM
(
SELECT col, 1 AS rank
FROM Table1
UNION ALL
SELECT col, 2 AS rank
FROM Table2
) t
ORDER BY t.rank,
t.col