Thread: Get a row by it's number

Get a row by it's number

From
Boszormenyi Laszlo
Date:
Hello!

 Is there any way to execute a select, and get only a specified row (let's
say the third one)?

Thanks in advance,
    Laszlo Boszormenyi


Re: Get a row by it's number

From
Phil Meadway
Date:
By definition, relation database tables are unordered. This is because the
storage characteristics can change (say from ISAM to BTREE or HASH indexing)
without affecting the data content.  Do you want to retrieve the nth row from
a select ... order by statement? Or are you looking for the nth row added? Nth
row added can be achieved if you use an incrementing sequence counter when
adding.

Boszormenyi Laszlo wrote:

> Hello!
>
>  Is there any way to execute a select, and get only a specified row (let's
> say the third one)?
>
> Thanks in advance,
>         Laszlo Boszormenyi

--
Phil Meadway                          Tel.: +(44) 1444 892 274
Managing Director                     philip.meadway@esmltd.co.uk
Enterprise Systems Management Limited www.esmltd.co.uk


Attachment

Re: Get a row by it's number

From
Andrew McMillan
Date:
Boszormenyi Laszlo wrote:
>
> Hello!
>
>  Is there any way to execute a select, and get only a specified row (let's
> say the third one)?

SELECT ..... LIMIT 1,3

From the documentation... postgresql-doc/html/user/sql-select.htm

 :-)

Cheers,
                    Andrew.
--
_____________________________________________________________________
            Andrew McMillan, e-mail: Andrew@cat-it.co.nz
Catalyst IT Ltd, PO Box 10-225, Level 22, 105 The Terrace, Wellington
Me: +64 (21) 635 694, Fax: +64 (4) 499 5596, Office: +64 (4) 499 2267

Get a row by it's number from (re)select

From
Boszormenyi Laszlo
Date:
Hello!

On Thu, 20 Jul 2000, Phil Meadway wrote:

> Do you want to retrieve the nth row from
> a select ... order by statement? Or are you looking for the nth row added? Nth
> row added can be achieved if you use an incrementing sequence counter when
> adding.

 To simplify the things, I do something like this:
execute a 'select * from mytable' from a cgi, then I write one of the
columns into options (the html tag). I generate unique name for them
ofcourse. When you submit your choice, an other cgi would display the full
row for that entry.
I know it can be done with the where clause too, but I'm intrested.

Thanks the help,
    Laszlo Boszormenyi