A lateral derived table is a special type of derived table that uses the LATERAL keyword to specify a derived table that can reference fields from other tables or derived tables previously defined in the same FROM clause. This allows subqueries within the derived table to depend on tables defined in the same FROM clause, enabling access to their column values.
The main characteristic of lateral derived tables is their ability to reference columns from tables defined earlier in the FROM clause, a capability that regular derived tables do not possess.
Examples
SELECT *
FROM A, LATERAL (SELECT * FROM B WHERE B.col1 = A.col1) AS derived_table;
References
For more information about lateral derived tables, see Lateral derived tables.
