tencent cloud

Cloud Log Service

UNION Syntax

다운로드
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-05-06 19:04:04
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:





도움말 및 지원

문제 해결에 도움이 되었나요?

피드백