tencent cloud

Cloud Log Service

EXCEPT Syntax

PDF
Focus Mode
Font Size
Last updated: 2026-05-06 19:06:14
The EXCEPT syntax is used to combine the analysis results of two SELECT statements, returning only the rows that exist in the first result set but not in the second.

Syntax Format

* | SELECT [column name(KEY)] FROM table1 EXCEPT 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 combined.
If the SELECT result contains duplicate rows, EXCEPT retains only one instance of each.

Syntax Example

Combine two tables with only one column to get the rows that exist in table one but not in table two. Among them, the first table has two rows with values of 42 and 13, respectively; the second table has only one row with a value of 13.
* | SELECT * FROM (VALUES 42,13)
EXCEPT
SELECT * FROM (VALUES 13)
Return result:




Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback