List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:April 5 2001 2:32am
Subject:Re: Limit
View as plain text  
In the last episode (Apr 04), Mat Murdock said:
>    If I understand the manual correctly when I do a  "select blah
>    from blah where blah = blah order by blah limit 10" Mysql finds
>    the first 10 matching records and then sorts those records.  How
>    do I have it first sort the database and then take the first 10
>    records?

It does that already.  In general, you can think of each SQL phrase
being applied to the resultset in order.  WHERE gets run, then GROUP
BY, then ORDER BY, then HAVING, then LIMIT (which explains why you
can't put a count() clause in WHERE, because the database doesn't even
know the count until the GROUP BY stage).

	Dan Nelson
LimitMat Murdock5 Apr
  • Re: LimitPaul DuBois5 Apr
    • Re: Limithooker5 Apr
      • Re: LimitDan Nelson5 Apr
  • Re: LimitJeremy Zawodny5 Apr
  • Re: LimitDan Nelson5 Apr