Solved

limit and offset clauses

Posted on 2002-04-07
3
2,649 Views
Last Modified: 2008-03-17
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
0
Comment
Question by:keithcsl
3 Comments
 
LVL 10

Accepted Solution

by:
bret earned 50 total points
ID: 6924389
There is no direct equivalent.

You can use "set rowcount <x>" to limit the results of a query to <x> 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
0
 
LVL 6

Expert Comment

by:ChrisKing
ID: 9947788
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: bret

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

ChrisKing
EE Cleanup Volunteer
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Time Syntax 4 300
SQL Syntax 6 396
sybase optimizer statistics 2 44
SQL, Updating Statistics take too long for 60GB database 5 132
This article outlines why you need to choose a backup solution that protects your entire environment – including your VMware ESXi and Microsoft Hyper-V virtualization hosts – not just your virtual machines.
This problem is more common than not and I will show you some things to check to solve this problem.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question