Available in versions: Dev (3.22) | Latest (3.21) | 3.20 | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12
INTERSECT ALL
Supported by ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
INTERSECT ALL is the operation that produces only those values that are returned by both subselects without removing duplicates.
SELECT ID FROM BOOK INTERSECT ALL SELECT ID FROM AUTHOR
create.select(BOOK.ID).from(BOOK)
.intersectAll(
create.select(AUTHOR.ID).from(AUTHOR))
.fetch();
Dialect support
This example using jOOQ:
select(BOOK.ID).from(BOOK).intersectAll(select(AUTHOR.ID).from(AUTHOR)).orderBy(BOOK.ID)
Translates to the following dialect specific expressions:
Aurora Postgres, CockroachDB, DB2, Databricks, DuckDB, HSQLDB, MariaDB 10.5+, MySQL 8.0.31+, Oracle 20c+, Postgres, Spanner, Sybase, Teradata, Trino, YugabyteDB
SELECT BOOK.ID FROM BOOK INTERSECT ALL SELECT AUTHOR.ID FROM AUTHOR ORDER BY ID
ClickHouse
SELECT t.* FROM ( SELECT BOOK.ID FROM BOOK INTERSECT ALL SELECT AUTHOR.ID FROM AUTHOR ) t ORDER BY ID
ASE, Access, Aurora MySQL, BigQuery, Exasol, Firebird, H2, Hana, Informix, MariaDB 10.0 to 10.4, MemSQL, MySQL 5.6 to 8.0.20, Oracle 18c, Redshift, SQLDataWarehouse, SQLServer, SQLite, Snowflake, Vertica
/* UNSUPPORTED */
Generated with jOOQ 3.21. Support in older jOOQ versions may differ. Translate your own SQL on our website
Feedback
Do you have any feedback about this page? We'd love to hear it!