Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Everything starts with a FROM table.

  2. The FROM table (1) is JOIN with other tables ON some constraints to produce a new table.

  3. Then the table (2) above is pruned horizontally with WHERE by dropping all the records no not matching the conditions

  4. The new table (3) is pruned vertically then, to match the SELECT columns only.

  5. DISTINCT removes all the duplicate records in (4)

  6. GROUP BY will create a new table from (5) grouping by the provide provided columns.

  7. HAVING will prune the previous (6) table by removing all the records no matching that don't match the conditions. HAVE acts similarly to the WHERE clause for the GROUP BY.

  8. The filtered grouped table (7) will be ORDER BY some columns

  9. OFFSET N will skip N first records in (8)

  10. and LIMIT M will take the output table from (9) and remove all the records after the M first ones.

...