All Products
Search
Document Center

PolarDB:INTERSECT clause

Last Updated:Mar 28, 2026

The INTERSECT operator returns rows that appear in both result sets. Unlike UNION, which combines and deduplicates results, INTERSECT narrows them to only the overlap.

Syntax

select_statement INTERSECT select_statement

Each select_statement is a SELECT statement that does not include an ORDER BY or FORUPDATE clause.

How it works

INTERSECT computes the set intersection of rows returned by two SELECT statements. A row appears in the output only if it exists in both result sets. Duplicate rows are removed from the result automatically.

Operator precedence

When a query contains multiple set operators, INTERSECT binds more tightly than UNION. The expression:

A UNION B INTERSECT C

is evaluated as:

A UNION (B INTERSECT C)

Multiple INTERSECT operators at the same level are evaluated left to right. Use parentheses to make the evaluation order explicit when mixing INTERSECT with UNION.

Limitations

  • Each SELECT statement cannot contain an ORDER BY or FORUPDATE clause.