querySlice

Returns a query containing a subset of another query

querySlice(query, offset [, length]) → returns query

Member Function Syntax

query.slice(offset [, length])

This function requires Lucee. Not supported on Adobe ColdFusion.

querySlice Argument Reference

query query
Required

offset number
Required

The first row to include in the new query

length number

The number of rows to include in the new query, defaults to all remaining rows

Examples sample code invoking the querySlice function


Create a query with 4 rows and return a new query containing the 2nd and 3rd rows of the first

data = [
	[ 1,'James' ],
	[ 2,'Alfred' ],
	[ 3,'Amisha' ],
	[ 4,'Terri' ]
];
myQuery = QueryNew( 'ID,name','int,varchar',data );
result = QuerySlice( myQuery,2,2 );
Dump( var='#result#' );

Using a member function

data = [
	[ 1,'James' ],
	[ 2,'Alfred' ],
	[ 3,'Amisha' ],
	[ 4,'Terri' ]
];
myQuery = QueryNew( 'ID,name','int,varchar',data );
result = myQuery.slice( 2,2 );
Dump( var='#result#' );

Fork me on GitHub