SQL term used to describe when a `SELECT` statement is used as part of a larger SQL statement. The larger statement may be DML and is always found within brackets or parenthesis.
SQL term used to describe when a SELECT
statement is used as part of a larger SQL statement. The larger statement may be DML and is always found within brackets or parenthesis.
Basic example:
SELECT f.column, (SELECT b.col FROM BAR b) AS col2
FROM FOO f
Correlated:
SELECT f.column, (SELECT b.col FROM BAR b WHERE b.col2 = f.col2) AS col2
FROM FOO f
Derived Table/Inline View:
SELECT f.*
FROM (SELECT t.* FROM FOOBAR t) AS f
IN/NOT IN:
SELECT f.*
FROM FOO f
WHERE f.column IN (SELECT b.col FROM BAR b)
SELECT f.*
FROM FOO f
WHERE f.column NOT IN (SELECT b.col FROM BAR b)
EXISTS/NOT EXISTS:
SELECT f.*
FROM FOO f
WHERE EXISTS (SELECT NULL FROM BAR b WHERE b.col = f.column)
SELECT f.*
FROM FOO f
WHERE NOT EXISTS (SELECT NULL FROM BAR b WHERE b.col = f.column)