Wednesday, July 20, 2005
From the Edge: Using the New LIMIT Syntax
Section: New and Enhanced Commands
Chapter: Running R:BASE Your Way!
Platforms: R:BASE 7.5, V-8 "Turbo", Oterro 3.5/8.0
Supported Builds:
. R:BASE 7.5 (7.5.11.30720 or higher)
. R:BASE V-8 "Turbo" (8.0.9.30720 or higher)
. Oterro 3.5 and Oterro 8.0 (Private Beta)
Among major tools, features and enhancements, R:BASE 7.5 for Windows,
R:BASE V-8 "Turbo" for Windows, Oterro 3.5 and Oterro 8.0, include
the support for new LIMIT syntax. Of course the traditional command
with WHERE LIMIT = ... is also supported as before.
New Syntax:
LIMIT {[offset,] row_count | row_count OFFSET offset}
Examples: (Using Bluzvan Database):
SELECT * FROM Albums LIMIT 0,30
Gets rows 1-30 from Albums table
SELECT * FROM Albums LIMIT 5,10
Gets rows 6-15 from Albums table
SELECT * FROM Albums LIMIT 10
Gets the first 10 rows from Albums table
The LIMIT clause can be used to constrain the number of rows returned
by the SELECT statement. LIMIT takes one or two numeric arguments,
which must be integer constants.
With two arguments, the first argument specifies the offset of the
first row to return, and the second specifies the maximum number of
rows to return. The offset of the initial row is 0 (not 1):
SELECT * FROM table LIMIT 5,10
Retrieves rows 6-15
To retrieve all rows from a certain offset up to the end of the result
set, you can use some large number for the second parameter. This
statement retrieves all rows from the 96th row to the last:
SELECT * FROM table LIMIT 95,99999999
With one argument, the value specifies the number of rows to return
from the beginning of the result set:
SELECT * FROM table LIMIT 5
Retrieve first 5 rows
In other words, LIMIT n is equivalent to LIMIT 0,n.
A PDF version of this document is also available at:
From The Edge: http://www.razzak.com/fte
(Powered by R:WEB Suite)
Enjoy and make sure to have fun!
Very Best R:egards,
Razzak.