limit 0,10 within SELECT ..... FROM ...... - Mailing list pgsql-general

From Lee Kindness
Subject limit 0,10 within SELECT ..... FROM ......
Date
Msg-id 15810.36306.101194.503590@kelvin.csl.co.uk
Whole thread Raw
In response to limit 0,10 within SELECT ..... FROM ......  ("Paul Ottar Tornes" <critical@tiscali.no>)
List pgsql-general
Probably because you're really wanting to do:

 SELECT id, tittel, dato, kilde, referat
  FROM nyheter ORDER BY desc LIMIT 10, 0

(i.e. got the arguments the wrong way round) It's much more intuitive
to use the "LIMIT n OFFSET m" syntax.

Lee.

Paul Ottar Tornes writes:
 > I run PostgreSQL and have some questions:
 >
 >
 > How come
 >     $query = "SELECT id, tittel, dato, kilde, referat FROM nyheter order by id desc limit 0,10";
 > Does not display any posts in my news script, but
 >     $query = "SELECT id, tittel, dato, kilde, referat FROM nyheter order by id desc limit 10";
 > Shows the last 10.?
 >
 > And:
 >
 > How come
 >     $query = "SELECT id, tittel, dato, kilde, referat FROM nyheter order by id desc limit 10,20";
 > Displays posts 5 to 14, and not 10 to 20?!
 >

pgsql-general by date:

Previous
From: Darren Ferguson
Date:
Subject: Re: limit 0,10 within SELECT ..... FROM ......
Next
From: Ken Guest
Date:
Subject: postgres on a FreeBSD 4.5 box