Re: select single entry and its neighbours using direct-acess

From: peter pilsl <pilsl(at)goldfisch(dot)at>
To: Pierre-Frédéric Caillaud <lists(at)boutiquenumerique(dot)com>, PostgreSQL List <pgsql-general(at)postgresql(dot)org>
Subject: Re: select single entry and its neighbours using direct-acess
Date: 2004-12-06 10:25:22
Message-ID: 41B43392.3010702@goldfisch.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Pierre-Frédéric Caillaud wrote:
>
>> select id from mytable where id=45 order by name,name2;
>
>
> Why do you want to select id if you already know it ?
> Do you not want to specify a starting value for name and name2 ?
>
> I'll presume you want to select a row by its 'id' and then get the
> previous and next ones in the name, name2 order. I'll guess the id is
> UNIQUE so these two other rows won't have the same id.
>
> If I guessed right I have the solution, if I'm not please explain
> what you wanna do more precisely ;)
>

sorry for being unclear.

but you guessed right. ID is UNIQUE and and I want to select a row by
its ID and also get the previous and next ones in the name, name2-order.

For the selected row I need all datafields and for the next and previous
I need only the ID (to have it referenced on the dataoutputpage for a
certain row).

I'm very looking forward for your solution.
thnx a lot,

peter

>>
>> and then I'd like to select the two entries that would come before
>> and after according to the order "name,name2";
>> id is not ordered, but there is an index on (name,name2) so the
>> needed infomation about previous, next should be stored somewhere in
>> this index.
>>
>> My current solution is to read all the data without the WHERE-clause
>> and then fetch the needed ones, which is quite time-demanding.
>>
>> thnx,
>> peter
>>
>>
>>
>
>

--
mag. peter pilsl
goldfisch.at
IT-management
tel +43 699 1 3574035
fax +43 699 4 3574035
pilsl(at)goldfisch(dot)at

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew M 2004-12-06 10:53:48 Re: SSL confirmation - No trusted certificate found
Previous Message Pierre-Frédéric Caillaud 2004-12-06 10:12:17 Re: select single entry and its neighbours using direct-acess to index?