Page 1 of 1

[SOLVED] Skip a record

Posted: Fri Oct 01, 2004 9:46 am
by hairyjim
Is it possible to skip the first found record from a table?

Cheers
Jim

LIMIT

Posted: Fri Oct 01, 2004 10:01 am
by phpScott
use LIMIT in your query.

Code: Select all

select * from someTable LIMIT 2, 30
will return the first 30 results but miss the first
syntax is LIMIT startAt, how many

Posted: Fri Oct 01, 2004 10:08 am
by hairyjim
Ahhh great.

I looked through the MySQL Docs for SKIP it never even occurred to me to actually read up on LIMIT.

Cheers.

You learn something new every day and forget something else :?

Posted: Fri Oct 01, 2004 10:38 am
by Jean-Yves
Be aware that the first record is record 0, not 1:
The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments. The arguments must be integer constants. If two arguments are given, the first specifies the offset of the first row to return, the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):
So you need to limit 1,30 in the example above

you right

Posted: Fri Oct 01, 2004 11:03 am
by phpScott
I couldn't remeber of the top of my head where the limit clause starts at.
thanks Jean-Yves for the reminder.