Real Software Forums
http://forums.realsoftware.com/

how it works LIMIT 20 OFFSET 20
http://forums.realsoftware.com/viewtopic.php?f=3&t=48033
Page 1 of 1

Author:  jetpr [ Sat Jun 01, 2013 2:05 am ]
Post subject:  how it works LIMIT 20 OFFSET 20

Select * from Inventory Order By Description LIMIT 20 OFFSET 20

how i can show some record and continue with more record to get to the last one

this is to fill a listBox

:idea:

Author:  jetpr [ Sat Jun 01, 2013 12:27 pm ]
Post subject:  Re: how it works LIMIT 20 OFFSET 20

like progressive RecordSet to fill a webListBox
:idea:

Author:  Specialised [ Sun Jun 02, 2013 3:00 am ]
Post subject:  Re: how it works LIMIT 20 OFFSET 20

SELECT * FROM `your_table` LIMIT 0, 10

This will display the first 10 results from the database.
SELECT * FROM `your_table` LIMIT 5, 5

This will show records 6, 7, 8, 9, and 10

Some people like to use OFFSET for readability, and its perfectly valid last I checked.

So to paginate you would do something like the following with count and offset being global variables (or handle them anyway you want) db is a global property in app (or if web edition a session property) while the db connection is done elsewhere (prior naturally).

db.sqlselect("SELECT * FROM `your_table` LIMIT " + cstr(i * count) + ", " + cstr(offset))


the variable i is a multiplier so your results are paginated and should be zero based. You increment i every time the "next" pagination button is clicked. It also works in reverse, the previous page of results would decrement the counter. You need to check i is never less than zero or it will return an sql error.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/