Re: find next in an index

From: Neil Dugan <postgres(at)butterflystitches(dot)com(dot)au>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: find next in an index
Date: 2005-02-13 04:35:31
Message-ID: 1108269331.6024.21.camel@postgresql.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, 2005-02-12 at 21:47 -0600, Bruno Wolff III wrote:
> On Sun, Feb 13, 2005 at 14:03:02 +1100,
> Neil Dugan <postgres(at)butterflystitches(dot)com(dot)au> wrote:
> > Hi,
> > I am trying to find out how to get the next record according to a
> > particular index.
> > I have a table with a name field and a serial field. The name field
> > isn't unique so I made an index on name(varchar) & serialno(bigserial).
> > I also have an index just on 'name'. I am having trouble working out
> > the syntax for the query.
> >
> > select * from table where name>='jack' and serialno!='2'
> > order by name,serialno;
> >
> > I don't think this will work under all circumstances.
> >
> > Any help appreciated. Thanks.
>
> I think using OFFSET 1 and LIMIT 2 with an appropiate WHERE clause
> will get you want you want. If you are going to keep stepping through
> the list, you might want to use a cursor.
>
With cursors is it possible to set the cursor to the location of a
particular row (found by another select query). The documentation say
you can set at a particular row number, but I would like to move the
cursor to the same record as found by another query (same index, same
fields).

In response to

Browse pgsql-general by date

  From Date Subject
Next Message elein 2005-02-13 04:40:45 Re: regular expressions in query
Previous Message Bruno Wolff III 2005-02-13 03:47:39 Re: find next in an index