mysql执行顺序

myWang / 2023-05-07 / 原文

Mysql语法顺序,即当sql中存在下面的关键字时,它们要保持这样的顺序:

 

  1. select[distinct]
  2. from
  3. join(如left join)
  4. on
  5. where
  6. group by
  7. having
  8. union
  9. order by
  10. limit

 


 

Mysql执行顺序,即在执行时sql按照下面的顺序进行执行:

 

  1. from
  2. on
  3. join
  4. where
  5. group by
  6. having
  7. select
  8. distinct
  9. union
  10. order by