New topic: how it works LIMIT 20 OFFSET 20
<http://forums.realsoftware.com/viewtopic.php?t=48033> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message jetpr Post subject: how it works LIMIT 20 OFFSET 20Posted: Sat Jun 01, 2013 2:05 am Joined: Wed Sep 20, 2006 5:12 pm Posts: 679 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 _________________ 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 jetpr Post subject: Re: how it works LIMIT 20 OFFSET 20Posted: Sat Jun 01, 2013 12:27 pm Joined: Wed Sep 20, 2006 5:12 pm Posts: 679 Location: Puerto Rico like progressive RecordSet to fill a webListBox _________________ 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 Specialised Post subject: Re: how it works LIMIT 20 OFFSET 20Posted: Sun Jun 02, 2013 3:00 am Joined: Thu Aug 26, 2010 6:57 am Posts: 568 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 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
