tencent cloud

Cloud Log Service

UNION Syntax

Download
聚焦模式
字号
最后更新时间: 2026-05-06 19:04:04
本文档由 AI 翻译
The UNION syntax is used to merge analysis results of multiple SELECT statements.

Syntax Format

* | SELECT [column name(KEY)] FROM table1 UNION SELECT [column name(KEY)] FROM table2
The analysis results of each SELECT statement should have the same number of columns and the same field types to be merged.
If the SELECT result contains duplicate rows, UNION retains only one instance of each by default. To retain all, use UNION ALL.

Syntax Example

Merge two tables that have only one column. Among them, the first table has only one row with the value 13, and the second table has two rows with values 42 and 13. Merge the duplicate rows.
* | SELECT * FROM (VALUES 13)
UNION
SELECT * FROM (VALUES 42,13)
Return result:



Merge two tables that have only one column. Among them, the first table has only one row with the value 13, and the second table has two rows with values 42 and 13. Do not merge the duplicate rows.
* | SELECT * FROM (VALUES 13)
UNION ALL
SELECT * FROM (VALUES 42,13)
Return result:





帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈