|
|
Question : limit and offset clauses
|
|
Hi
I am migrating a mySQL application to Sybase. What is the equivalent SQL in Sybase for the LIMIT OFFSET clauses? ie to select 5 rows (limit) starting from the 10th row (offset).
Keith
|
Answer : limit and offset clauses
|
|
There is no direct equivalent.
You can use "set rowcount " to limit the results of a query to rows, but there is no offset.
You can also select the result set (full or limited by SET ROWCOUNT) into a temptable, adding an identity column, then use the values in the identity column to select subsets:
select a,b,c, rownum = identity(8) into #foo from mytable select * from #foo where rownum between 10 and 15 drop table #foo go
|
|
|
|
|