How SQL query results are generated
From the book – “SQL: The Complete Reference”…
To generate the query results for a single-table SELECT statement, follow these steps:
// 1. FROM Clause:
Selecting the table or view containing data to be retrieved
// 2. WHERE clause:
Selecting specific rows from the table.
If there is a WHERE clause, apply its search condition to each row of the table, retaining those rows for which the search condition is TRUE, and discarding those rows for which it is FALSE or NULL.
// 3. SELECT clause:
Generating the specific columns of query results and eliminating
duplicate rows, if requested.
For each remaining row, calculate the value of each item in the select list to produce a single row of query results. For each column reference, use the value of the column in the current row.
// 4. If SELECT DISTINCT is specified, eliminate any duplicate rows of query results that
were produced.
// 5. ORDER BY clause:
If there is an ORDER BY clause, sort the query results as specified.
… The rows generated by this procedure comprise the query results.
No trackbacks yet.