完整SQL语句

  1. SELECT DISTINCT <column_list>
  2. FROM <table_name_1>
  3. <join_type> JOIN <table_name_2> ON <join_condition>
  4. WHERE <where_codition>
  5. GROUP BY <group_by_list>
  6. HAVING <having_condition>
  7. ORDER BY <order_by_condition>
  8. LIMIT {[offset,] row_count | row_count OFFSET offset_num}

SQL 执行顺序

  1. FROM
  2. ON
  3. JOIN
  4. WHERE
  5. GROUP BY
  6. SELECT DISTINCT
  7. ORDER BY
  8. LIMIT {[offset,] row_count | row_count OFFSET offset_num}