We utilize SQL queries to access a collection of records that are stored in our database tables. Clauses are the building blocks of SQL queries. To get the right outcomes, these clauses must be executed in a specific order. SQL query execution order is the name given to this sequence of operations.
𝗦𝗤𝗟 𝗾𝘂𝗲𝗿𝘆 𝗲𝘅𝗲𝗰𝘂𝘁𝗶𝗼𝗻 𝗼𝗿𝗱𝗲𝗿 refers to how the query clauses are evaluated in accordance with the requirements or how to optimize database search results. We use clauses in a specific order known as the SQL query execution order, similar to how we plan something step by step and arrive at the end result.
- 𝗙𝗥𝗢𝗠 - tables are joined to get the base data.
- 𝗪𝗛𝗘𝗥𝗘 - the base data is filtered.
- 𝗚𝗥𝗢𝗨𝗣 𝗕𝗬 - the filtered base data is grouped.
- 𝗛𝗔𝗩𝗜𝗡𝗚 - the grouped base data is filtered.
- 𝗦𝗘𝗟𝗘𝗖𝗧 - the final data is returned.
- 𝗢𝗥𝗗𝗘𝗥 𝗕𝗬 - the final data is sorted.
- 𝗟𝗜𝗠𝗜𝗧 - the returned data is limited to row count.
Preview - 01
Preview - 02