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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| 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; |
| |||
| 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 |
| ||||
| 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. |