9.19.8.Query Expressions

< non-join query expression > ::=
      < non-join query term >
    | < query expression > UNION  [ ALL ]
          [ < corresponding spec > ] < query term >
    | < query expression > EXCEPT [ ALL ]
          [ < corresponding spec > ] < query term >

< corresponding spec > ::=
    CORRESPONDING [ BY < left parent >
        < corresponding column list > < right parent > ]

Queries can be combined by set operators UNION, INTERSECTION and EXCEPT (set difference). The ALL keyword will allow duplicate rows in the result set. The CORRESPONDING BY clause allows specifying which columns will be used to determine the equality of rows from the left and right operands.

 select OrderID from Orders except
    corresponding by (OrderID) select OrderID from Order_Details

will produce the OrderID's of orders that have no Order_Details. This is equivalent to: select OrderID from Orders a where not exists (select 1 from Order_Details b where a.OrderID = b.OrderID)

Note that the queries, although to a similar effect are executed quite differently. There may be significant differences in performance.