Re: Question about restricting the number of rows returned from a query.

From: Stephen Ingram <ingram(at)samsix(dot)com>
To: Philip Hallstrom <philip(at)adhesivemedia(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Question about restricting the number of rows returned from a query.
Date: 2002-02-20 21:11:10
Message-ID: 20020220211712.ZGRA6925.femail12.sdc1.sfba.home.com@there
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Wednesday 20 February 2002 03:50 pm, Philip Hallstrom wrote:
> See the LIMIT and OFFSET options in the SELECT command in the manual.
>

Thanks Philip. I did *try* and get onto the postgres sites, but it
kept timing out, so I lazily asked here. Sorry.

And now I found this is psql... nice!

Thanks again,

steve

lazygitdb=# \h select
Command: SELECT
Description: Retrieves rows from a table or view
Syntax:
SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
* | expression [ AS output_name ] [, ...]
[ FROM from_item [, ...] ]
[ WHERE condition ]
[ GROUP BY expression [, ...] ]
[ HAVING condition [, ...] ]
[ { UNION | INTERSECT | EXCEPT [ ALL ] } select ]
[ ORDER BY expression [ ASC | DESC | USING operator ] [, ...] ]
[ FOR UPDATE [ OF tablename [, ...] ] ]
[ LIMIT { count | ALL } [ { OFFSET | , } start ]]

where from_item can be:

[ ONLY ] table_name [ * ]
[ [ AS ] alias [ ( column_alias_list ) ] ]
|
( select )
[ AS ] alias [ ( column_alias_list ) ]
|
from_item [ NATURAL ] join_type from_item
[ ON join_condition | USING ( join_column_list ) ]

> -philip
>
> On Wed, 20 Feb 2002, Stephen Ingram wrote:
> > Hi,
> >
> > If I am running a query I know could return 1000's of rows;
> > is there a PG way to say to just return the first, say, 50 rows?
> >
> > cheers
> >
> > steve
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 3: if posting/reading through Usenet, please send an appropriate
> > subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> > message can get through to the mailing list cleanly

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Stephen Ingram 2002-02-20 21:17:16 Re: Question about restricting the number of rows
Previous Message Mo Holkar 2002-02-20 21:05:43 Re: Question about restricting the number of rows