Is MySQL LIMIT applied before or after ORDER BY?

后端 未结 3 2068
孤街浪徒
孤街浪徒 2020-12-28 12:50

Which one comes first when MySQL processes the query?

An example:

SELECT pageRegions
FROM pageRegions WHERE(pageID=?) AND(published=true) AND (publis         


        
3条回答
  •  一整个雨季
    2020-12-28 13:25

    Yes, it's after the ORDER BY. For your query, you'd get the record with the highest publishedOn, since you're ordering DESC, making the largest value first in the result set, of which you pick out the first one.

提交回复
热议问题