View Single Post

   
  #3 (permalink)  
Old 02-28-2008, 11:29 AM
Chris
 
Posts: n/a
Default Re: Understanding LIMIT?

On 3 Nov, 18:36, hadronqu...@gmail.com wrote:
> Chris <matchett...@googlemail.com> writes:
> > Can someone explain why the query below doesn't do as I hoped it would
> > do...return the ten records proceeding the row with an id of 200744?
> > Please note that id is not an auto increment and can jump from 200744
> > to 200801.

>
> > SELECT * FROM weeknumber WHERE id > 200744 ORDER BY id LIMIT 0,10

>
> > Many thanks,

>
> > Chris

>
> Because you have ">" instead of "<"? proceeding means to go before.
>
> Did you mean something more like
>
> select * from loginattempts where id < 49 order by id desc limit 3;


Thanks.

This query is from a pagination script, I want to stop pagination
after 10 records corresponding to the current date's week number i.e.
200744 is Year 2007, Week 44. I can't just add 10 to 200744 as there
are only 52/53 weeks in a year.

However, you are right about 'less than'. After posting this thought
had also crossed my mind...I will pick a future date, caluate the year/
week number from that and work backwards.

Thanks again,

Chris


Reply With Quote