Pierre-Frédéric Caillaud <[EMAIL PROTECTED]> writes:
> One could always use ARRAY[name,name2] > ARRAY['b','a']
> But it is NOT index-friendly...
It won't use an existing two-column index but you can create an expression
index on array[name,name2] and this expression will use it. It w
I thought the planner had an automatic rewriter for these situations.
No. There was a prior discussion of this, saying that we really ought
to support the SQL-spec row comparison syntax:
What I meant was that I thought the planner could rewrite :
(A and C) or (A AND B) as A and (B or
=?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= <[EMAIL PROTECTED]> writes:
> SELECT * FROM test WHERE (name='b' and name2>'a') OR (name>'b') ORDER BY
> name,name2 ASC LIMIT 1;
>> Write that WHERE clause instead as:
>> WHERE name>='b' AND (name>'b' OR (name='b' AND name2>'a'))
>> This is logically e
SELECT * FROM test WHERE (name='b' and name2>'a') OR (name>'b') ORDER BY
name,name2 ASC LIMIT 1;
Write that WHERE clause instead as:
WHERE name>='b' AND (name>'b' OR (name='b' AND name2>'a'))
This is logically equivalent, but it gives the planner a better handle on
how to use an index scan to sat
On 2004-12-06, Pierre-Frédéric Caillaud <[EMAIL PROTECTED]>
wrote:
> SELECT * FROM test WHERE (name='b' and name2>'a') OR (name>'b') ORDER BY
> name,name2 ASC LIMIT 1;
Write that WHERE clause instead as:
WHERE name>='b' AND (name>'b' OR (name='b' AND name2>'a'))
This is logically equivalent,
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 dat
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
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
Is there an easy solution for this?
I'd like to select a single entry from a table and the entries that
would be previous and next given to a certain order.
like
select id from mytable where id=45 order by name,name2;
and then I'd like to select the two entries that would come before and
after a