SQL - SubqueriesWhat happens when a correlated subquery is executed in SQL?AThe subquery runs only once before the outer queryBThe subquery runs independently without referencing the outer queryCThe subquery runs after the outer query completesDThe subquery runs once for each row of the outer queryCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand correlated subquery executionA correlated subquery depends on the outer query's current row, so it must run repeatedly for each row.Step 2: Compare execution modelsUnlike a simple subquery that runs once, a correlated subquery executes once per outer row to use that row's data.Final Answer:The subquery runs once for each row of the outer query -> Option DQuick Check:Correlated subquery execution = runs per outer row [OK]Quick Trick: Correlated subqueries run repeatedly per outer row [OK]Common Mistakes:MISTAKESThinking subquery runs only onceConfusing correlated with non-correlated subqueriesAssuming subquery runs after outer query
Master "Subqueries" in SQL9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More SQL Quizzes Aggregate Functions - COUNT function behavior - Quiz 12easy GROUP BY and HAVING - GROUP BY single column - Quiz 4medium INNER JOIN - INNER JOIN syntax - Quiz 9hard INNER JOIN - INNER JOIN with ON condition - Quiz 4medium LEFT and RIGHT JOIN - LEFT JOIN vs RIGHT JOIN decision - Quiz 10hard Set Operations - EXCEPT (MINUS) for differences - Quiz 11easy Subqueries - Subquery with EXISTS operator - Quiz 10hard Table Constraints - Composite primary keys - Quiz 10hard Views - Updatable views and limitations - Quiz 14medium Views - Updatable views and limitations - Quiz 3easy