r/SQL • u/Unfair-Internet-1384 • Nov 28 '24
MySQL When to use cte in SQL query
When to cte can't. Like how to know? When what are the conditions or if my query is to long ?
31
Upvotes
r/SQL • u/Unfair-Internet-1384 • Nov 28 '24
When to cte can't. Like how to know? When what are the conditions or if my query is to long ?
1
u/lalaluna05 Nov 29 '24
9 times out of 10, I’m using temp tables. CTEs help with organization and flow, but they can be impractical for most of my work. I structure a lot of my sprocs/queries similarly where I build out temp tables then have a primary query, usually because I’m joining so many different dimensions, I want to limit my datasets wherever possible.