Exists Tupel Queries ?
Posted in 2000
Topics: SQL Development & Query Writing
Hello
Can anybody tell if it possible to ask for tupel in a
select statement ?
An example:
Normaly : select id from tab1 where ( a=2 and b=3 ) or
( a=3 and b=7 ) or
( a=5 and b=10)
Wanted somthing like this:
select id from tab1 where (a,b) in ({2,3},{3,7},{5,10})
Also i was interested if the normaly case could be simplified.
THANX to ALL
Thorsten
------------------------------------------------------
Thorsten Geelhaar Telefon: +49 231 5599 106
Dr. Materna GmbH Fax : +49 231 5599 100
Vosskuhle 37 e-mail : Thorsten.Geelhaar@materna.de
D-44141 Dortmund GERMANY
------------------------------------------------------
Thorsten Geelhaar wrote:
>
> Hello
>
> Can anybody tell if it possible to ask for tupel in a
> select statement ?
> An example:
>
> Normaly : select id from tab1 where ( a=2 and b=3 ) or
> ( a=3 and b=7 ) or
> ( a=5 and b=10)
>
> Wanted somthing like this:
>
> select id from tab1 where (a,b) in ({2,3},{3,7},{5,10})>
> Also i was interested if the normaly case could be simplified.
I don't know about simplified, but, depending on the context, it could
be made generic as follows
1. Insert the "query values" into a temp table
2. Do a join between tab1 and temptab.
Rudy
>
> THANX to ALL
>
> Thorsten
>
> ------------------------------------------------------
> Thorsten Geelhaar Telefon: +49 231 5599 106
> Dr. Materna GmbH Fax : +49 231 5599 100
>
> Vosskuhle 37 e-mail : Thorsten.Geelhaar@materna.de
> D-44141 Dortmund GERMANY
> ------------------------------------------------------
Thorsten Geelhaar wrote:
> Hello
>
> Can anybody tell if it possible to ask for tupel in a
> select statement ?
> An example:
>
> Normaly : select id from tab1 where ( a=2 and b=3 ) or
> ( a=3 and b=7 ) or
> ( a=5 and b=10)
>
> Wanted somthing like this:
>
> select id from tab1 where (a,b) in ({2,3},{3,7},{5,10})
In IDS.2000:
SELECT T.Id
FROM Foo T,
TABLE(MULTISET{ROW(2,3),ROW(3,7),ROW(5,10)
}::MULTISET(ROW( Num1
INTEGER NOT NULL,
Num2 INTEGER NOT NULL
) NOT NULL)
) S
WHERE T.A = S.Num1 AND T.B = S.Num2;
You can drop things like SET, MULTISET, and LIST into the FROM
clause.