Correlated subquery (also known synchronized subquery) is a subquery (a query nested inside another query) that uses values from the outer query.
Consider the following example:
SELECT * FROM users WHERE users.id IN (SELECT vip_users.id FROM vip_users WHERE vip_users.id = users.id)
The inner query depends on the values from the outer query.
Moreover the IN (...)
statement cannot be executed by itself because it depends on the values from users table. Such query is called a correlated subquery.
Login in to like
Login in to comment