It:
SELECT y.col_name, (SELECT x.column FROM TABLE x) AS your_subquery FROM TABLE y WHERE y.col = ?
... is a typical subquery in a SELECT . Some call it a "subtitle." It:
SELECT y.col_name, (SELECT x.column FROM TABLE x WHERE x.id = y.id) AS your_subquery FROM TABLE y WHERE y.col = ?
... is a correlated subquery. It correlates because the result of the subquery refers to the table in the external query ( y in this case).
Effectively just write any optional SELECT statement you want in the SELECT clause, but it must be surrounded by parentheses.
OMG Ponies
source share