Skip site navigation (1) Skip section navigation (2)

Re: Question about restricting the number of rows

From: Stephen Ingram <ingram(at)samsix(dot)com>
To: Mo Holkar <pgsql(at)digitalmindgames(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Question about restricting the number of rows
Date: 2002-02-20 21:17:16
Message-ID: 20020220212318.SYRC29054.femail24.sdc1.sfba.home.com@there (view raw or flat)
Thread:
Lists: pgsql-novice
On Wednesday 20 February 2002 04:05 pm, Mo Holkar wrote:
> At 20:03 20/02/02, Steve 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?
>
> Like this:
>
> SELECT * FROM table LIMIT 50;
>
> If you wanted rows 51-100 you'd use
>
> SELECT * FROM table LIMIT 50 OFFSET 50;
>
> and in general LIMIT n OFFSET m will return rows from m+1 to m+n inclusive.
>
> Bear in mind though that for 'the first 50' to be meaningful you'll likely
> have to be using an ORDER BY clause.
>
> best,
>
> Mo
>


Thanks Mo (and everyone).

I was using a distinct in my case and the results are
just what I need! =:o)

steve





>
>
>
> Mo Holkar
> Digital Mind Games -- log on to take over
> mo(dot)holkar(at)digitalmindgames(dot)com
> http://www.digitalmindgames.com
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

In response to

pgsql-novice by date

Next:From: Tuna ChatterjeeDate: 2002-02-20 21:20:03
Subject: Re: Question about restricting the number of rows returned
Previous:From: Stephen IngramDate: 2002-02-20 21:11:10
Subject: Re: Question about restricting the number of rows returned from a query.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group