Re: [SQL] How Can I limit the select result ?

From: Maarten Boekhold <maartenb(at)dutepp0(dot)et(dot)tudelft(dot)nl>
To: <mrpark(at)tinc(dot)co(dot)kr>
Cc: sql <pgsql-sql(at)postgreSQL(dot)org>
Subject: Re: [SQL] How Can I limit the select result ?
Date: 1998-07-24 07:57:15
Message-ID: Pine.SUN.3.91.980724095340.4169G-100000@dutepp0.et.tudelft.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, 24 Jul 1998, =?UNKNOWN?Q?=B9=DA=B9=CC=B7=E6?= wrote:

> I want to select like this...
>
> select * from any_table where table_field > any_no limit 10 order by
> table_field DESC;
>
> I want to select more than 1000 rows.
> But, I want to view only 10 from maximum to maximum -10.
>
> How can I ?
>
> I want to make the search engin using Postgresql.
> If more than 10000 rows, there's hard to query, I think...
> Does anybody know about this ?

use cursors:

begin;
declare C cursor for
select * from any_table
where table_field > 10
order by table_field DESC;
move forward 4590 in C;
fetch fetch 10 in C;
end;

I don't know how to move to the end of the result set. Maybe it's possible
to use 'move backward 10 in C' and then 'fetch forward 10 in C', you'll
have to try.

Maarten

_____________________________________________________________________________
| TU Delft, The Netherlands, Faculty of Information Technology and Systems |
| Department of Electrical Engineering |
| Computer Architecture and Digital Technique section |
| M(dot)Boekhold(at)et(dot)tudelft(dot)nl |
-----------------------------------------------------------------------------

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Guido Piazzi 1998-07-24 09:16:13 Re: [SQL] How Can I limit the select result ?
Previous Message The Web Administrator 1998-07-24 04:18:54 Sub Queries