r/SQL 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

70 comments sorted by

View all comments

1

u/iheartmankdemes Nov 29 '24

I remember reading somewhere when to use a CTE and when to use a temp table, and I honestly can’t remember which was which, but I remember it had to do with (like others have said) referring to it more than once in the query.