cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement paging query like mssql!

ximen
Participant
0 Kudos
492

mssql sql:

set statistics time on;
-- Paging query (general type)
select * from student
order by sno 
offset ((@pageIndex-1)*@pageSize) rows
fetch next @pageSize rows only;

-- Pagination query page 2, each page has 10 records
select * from student
order by sno  
offset 10 rows
fetch next 10 rows only ;

Where is the documentation on how to implement distributed query?

Accepted Solutions (0)

Answers (1)

Answers (1)

VolkerBarth
Contributor

You can "paginate" queries in SQL Anywhere via several forms of "row-limitation" clauses, either

SELECT TOP n START AT m ... FROM

or similar to MySQL via

SELECT ... FROM ... LIMIT x OFFSET y

or

SELECT ... FROM ... LIMIT y, x

where n = x and y = m -1 (i.e. START AT 21 is equivalent to OFFSET 20), and can be expressed with constants or variables.

It's documented, of course. (The doc link goes to version 17.0.1 but both clauses are avilable in version 12, too.

Note the following hint:

The LIMIT keyword is disabled by default. Use the reserved_keywords option to enable the LIMIT keyword.