[SOLVED] Skip a record

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
hairyjim
Forum Contributor
Posts: 219
Joined: Wed Nov 13, 2002 9:04 am
Location: Warwickshire, UK

[SOLVED] Skip a record

Post by hairyjim »

Is it possible to skip the first found record from a table?

Cheers
Jim
Last edited by hairyjim on Fri Oct 01, 2004 10:08 am, edited 1 time in total.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

LIMIT

Post 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
hairyjim
Forum Contributor
Posts: 219
Joined: Wed Nov 13, 2002 9:04 am
Location: Warwickshire, UK

Post 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 :?
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post 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
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

you right

Post by phpScott »

I couldn't remeber of the top of my head where the limit clause starts at.
thanks Jean-Yves for the reminder.
Post Reply