r/SQL • • Jun 15 '26

MySQL SQL Correlated Subqueries

Hey everyone, I’m about a week into learning SQL (doing a Data Analyst track) and I’ve officially hit my first major wall at data manipulation.

Regular subqueries make sense, but correlated subqueries are completely tripping me up.

Could anyone explain:

  • How they actually work under the hood?
  • Why they are different from non-correlated ones?
  • What we actually use them for, and are they basically just another version of a self-join?

Any simple analogies or step-by-step breakdowns would be massively appreciated. Thanks!

1 Upvotes

11 comments sorted by

View all comments

Show parent comment

1

u/Eleventhousand Jun 17 '26

Strange reply

0

u/jshine13371 Jun 17 '26

Yes your comment and downvote is.

Where are you confused from my comment that provides examples where a correlated subquery is the same or better of an implementation from a performance perspective?

1

u/Eleventhousand Jun 17 '26

If I can paraphrase:

Me: "It often performs more poorly. Sometimes you need to use a different technique."

You: "You are spreading misinformation. That's not always true. Sometimes its true, in your example its true, but sometimes it performs the same, and sometimes it performs better."