Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How to get the "next" row in a table?
Old 07-18-2011, 04:19 PM How to get the "next" row in a table?
Super Talker

Posts: 116
Trades: 0
I need a way to grab "the next row" from a table in a mysql database. The table has an index that auto increments, but some of the rows may be deleted. So, for instance, the table might look like this:

Code:
3
4
6
7
8
9
14
15
16
18
20
...
To get the first row, I believe I can go:

Code:
SELECT columns FROM table ORDER BY index LIMIT 1
That should give me the first row, right?

But after this, I'm not sure what to do. Say I've read the first row up to the second (index = 4), how do I then get the next row? ("the next row" being the third row with index = 6).

Thanks
Learnin' n00b is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-18-2011, 04:38 PM Re: How to get the "next" row in a table?
NullPointer's Avatar
Will Code for Food

Posts: 2,883
Name: Matt
Location: Irvine, CA
Trades: 0
Specify the offset as well as the number of rows you want:
Code:
SELECT columns FROM table ORDER BY index LIMIT 1, 1
The offset starts from 0 (the first row is 0, not 1).
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 07-18-2011, 09:47 PM Re: How to get the "next" row in a table?
Super Talker

Posts: 116
Trades: 0
Thanks!
Learnin' n00b is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to get the "next" row in a table?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14678 seconds with 11 queries