sajad torkamani

This is the order in which SQL executes a typical SQL query:

  • FROM
    • Gathers all the rows from the specified tables.
  • JOIN
    • Performs any joins between tables.
  • WHERE
    • Filters rows based on the specified condition(s).
  • GROUP BY
    • Groups all the filtered rows that share values for the specified column(s).
  • HAVING
    • Filters the grouped rows by the specified condition(s).
  • SELECT
    • Displays the columns specified in the SELECT clause.
  • DISTINCT
    • Removes duplicate rows from the result.
  • ORDER BY
    • Sorts the rows using the specified criteria.
  • LIMIT/OFFSET
    • Restricts the number of rows returned.
Tagged: SQL