更新时间:2022-02-22 GMT+08:00

SELECT UNION Syntax

常用语法

SELECT ...UNION [ALL | DISTINCT] 
SELECT ...[UNION [ALL | DISTINCT] SELECT ...]

示例

select userid from user union select orderid from ordertbl order by userid;
select userid from user union (select orderid from ordertbl group by orderid) order by userid;

语法限制

对于UNION中的每个SELECT,不支持使用多个同名的列。