- 
                Notifications
    You must be signed in to change notification settings 
- Fork 435
Set operations
        Rene Saarsoo edited this page Apr 19, 2025 
        ·
        9 revisions
      
    SQL standard defines the following set operations:
  UNION [ALL | DISTINCT]
| EXCEPT [ALL | DISTINCT]
| INTERSECT [ALL | DISTINCT]
All dialects support UNION, with rest there are variations:
  UNION {ALL | DISTINCT}
| EXCEPT DISTINCT
| INTERSECT DISTINCT
DB2:
  UNION [ALL]
| EXCEPT [ALL]
| INTERSECT [ALL]
  UNION [ALL | BY NAME]
| EXCEPT [ALL]
| INTERSECT [ALL]
Hive:
UNION [ALL | DISTINCT]
  UNION [ALL | DISTINCT]
| EXCEPT [ALL | DISTINCT]
| INTERSECT [ALL | DISTINCT]
| MINUS [ALL | DISTINCT]
UNION [ALL | DISTINCT]
N1QL:
  UNION [ALL]
| EXCEPT [ALL]
| INTERSECT [ALL]
  UNION [ALL]
| MINUS
| INTERSECT
  UNION [ALL | DISTINCT]
| EXCEPT [ALL | DISTINCT]
| INTERSECT [ALL | DISTINCT]
  UNION [ ALL ]
| EXCEPT
| INTERSECT
| MINUS
SingleStoreDB (union, intersect, except and minus):
  UNION [ALL | DISTINCT]
| EXCEPT
| INTERSECT
| MINUS
  UNION [ALL]
| EXCEPT
| MINUS
| INTERSECT
  UNION [ALL | DISTINCT]
| EXCEPT [ALL | DISTINCT]
| INTERSECT [ALL | DISTINCT]
  UNION [ALL]
| EXCEPT
| INTERSECT
TiDB:
UNION [ALL | DISTINCT]
  UNION [ALL]
| EXCEPT
| INTERSECT
  UNION [ALL | DISTINCT]
| EXCEPT [ALL | DISTINCT]
| INTERSECT [ALL | DISTINCT]