Solved

Sybase Sql Query for displaying 10 to 20 records (pagination)

Posted on 2007-11-30
4
2,795 Views
Last Modified: 2012-06-27
Hi Experts,

Can you please help to wrtie a query in sybase database.

For example result Select * from emp returns 100 rows.
I need queries to display first 1 to 20 and another query to display 20 to 40 etc.

Please help me on this.

Thanks,
Ganne
0
Comment
Question by:gannev
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:bret
ID: 20382899
0
 

Author Comment

by:gannev
ID: 20383454
Am a beginner, and am not understanding that.

Can you please write a simple code snippet for
select 10 to 20 records from emp table.


Appreciate your help
0
 
LVL 10

Accepted Solution

by:
bret earned 500 total points
ID: 20383524
select <primary key column>, rownum = identity(20) into #temp from emp
go
select e.* from emp e, #temp t where
t.pk = e.pk
and t.rownum >= 10
and t.rownum < 21
0
 

Author Comment

by:gannev
ID: 20384357
Hi Bret,

Thanks for this solution. It is working greatly. But this would lead me to write procedure.
I need a sql query for this. And I can call that query from my application(java appliction).

Thanks,
Ganne
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Syntax 6 400
How do I get SCOPE_IDENTITY working correctly. 3 859
SIMPLE QUESTION BACKUP AND RESTORE ORACLE DATABASE 13 91
restore master and user database in sybase ase 2 62
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 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