Unix Technical Forum

Understanding LIMIT?

This is a discussion on Understanding LIMIT? within the MySQL forums, part of the Database Server Software category; --> Can someone explain why the query below doesn't do as I hoped it would do...return the ten records proceeding ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 11:29 AM
Chris
 
Posts: n/a
Default Understanding LIMIT?

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 11:29 AM
hadronquark@gmail.com
 
Posts: n/a
Default Re: Understanding LIMIT?

Chris <matchett123@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;

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 11:29 AM
Paul Lautman
 
Posts: n/a
Default Re: Understanding LIMIT?

hadronquark@gmail.com wrote:
> Chris <matchett123@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

>

| proceeding means to go before.
Err, no it doesn't! Proceeding means "A course of action;" and "proceedings"
are things like legal actions.

"Preceding" (notice no "o" and no double "ee"), means
Existing or coming before another or others in time, place, rank, or
sequence; previous.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:13 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com