Mads Andersen
Mads Andersen

Reputation: 139

skip/bypass data on A mysql_query

I'm working on some charts and I need to find out how I can make my query skip x records on a select.

Lets say, I have 100 Records in my MySQL database.
and I want to select, but buypass 9, or skip 9 (whatever we should call it)..
so I'm selecting:
id 1
id 10
id 19 etc etc..

How am I able to do so in a query ?

I have tried to get the values in a for loop by incrementing $i with $offset (how many I want to bypass) and then use the $data[$i]['value']; but is was not able to get that to work.

Upvotes: 3

Views: 178

Answers (3)

A P
A P

Reputation: 457

select * from `users` where MOD(`id`,9) = 1

Upvotes: 2

Carsten Massmann
Carsten Massmann

Reputation: 28196

Try something like

Select * from foo where id%9=1

Upvotes: 2

Gigline
Gigline

Reputation: 297

The Mysql LIMIT command allows you to skip (10) records, and return (50) records

SELECT *
FROM FOO
LIMIT 10, 50

Upvotes: -1

Related Questions