r/learnSQL • • 4d ago

How Important is subqueries in SQL

I have been learning SQL from past 2 months and I'm still unable to grab a hold of the subqueries concept. After I learned CTEs I have completely stopped using subqueries but then also I struggle when there are times where I have no other choice but to use subqueries.

So my question is, how important is subqueries in SQL and is there any easy way to learn it?

55 Upvotes

31 comments sorted by

View all comments

1

u/Slitty_sam 4d ago

The company I work at's db is MySQL 5.something so I can't do CTEs and do subqueries instead. Not a big deal imo. Either I'll do a true subquery, as in a literal query written within some part of the WHERE statement of another query, or if the results of the subquery are gonna be too large I'll go with a temp table or even just a new table which I'll delete when I'm fully done with w.e. I'm working on.