Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed Oct 18, 2017 3:22 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: how it works LIMIT 20 OFFSET 20
PostPosted: Sat Jun 01, 2013 2:05 am 
Offline
User avatar

Joined: Wed Sep 20, 2006 5:12 pm
Posts: 680
Location: Puerto Rico
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:

_________________
Thanks for any contribution and God blesses all (I start Using RS in 10/12/2010)
Mac Mini with Lion v10.7.5 and Real Studio 2012r1 Pro And Windows 7 RS2012r1 Personal and Linux RS2012r1 Personal Register user
my Hobbies R/C Turbines Jets Models


Top
 Profile  
Reply with quote  
 Post subject: Re: how it works LIMIT 20 OFFSET 20
PostPosted: Sat Jun 01, 2013 12:27 pm 
Offline
User avatar

Joined: Wed Sep 20, 2006 5:12 pm
Posts: 680
Location: Puerto Rico
like progressive RecordSet to fill a webListBox
:idea:

_________________
Thanks for any contribution and God blesses all (I start Using RS in 10/12/2010)
Mac Mini with Lion v10.7.5 and Real Studio 2012r1 Pro And Windows 7 RS2012r1 Personal and Linux RS2012r1 Personal Register user
my Hobbies R/C Turbines Jets Models


Top
 Profile  
Reply with quote  
 Post subject: Re: how it works LIMIT 20 OFFSET 20
PostPosted: Sun Jun 02, 2013 3:00 am 
Offline
User avatar

Joined: Thu Aug 26, 2010 6:57 am
Posts: 569
Location: Sydney Australia
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.

_________________
Regards

Chris Musty
http://www.specialised.net.au
-----------------------------------------------
if date.shortdate >= 4/6/2013 then
msgbox "I am using Xojo - YAY!!!"
else
msgbox "I am still using RS 12r2.1 - BOO!!!"
end if

Win 8 Pro, Ubuntu 13.04, Mint and Debian(gnome and KDE)
AWS for Hosting and TKL for AMI's


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group