Order of Execution in a SQL Query
SQL Query Order of Execution Each SQL query begins with finding the data that we need in a database, this data is then filtered down into something that can be processed and understood as quickly as possible. Because each part of the query is executed sequentially, it’s important to understand the order of execution so that we know what results are accessible where. Let’s consider the below mentioned query : 1 2 3 4 5 6 7 8 9 SELECT DISTINCT column, AGG_FUNC(column_or_expression), … FROM mytable JOIN another_table ON mytable.column = another_table.column WHERE constraint_expression GROUP BY column HAVING constraint_expression ORDER BY column ASC/DESC LIMIT count OFFSET COUNT; Query order of execution 1. FROM and JOINs ...