Subject RE: [firebird-support] UNION and IN operator
Author Svein Erling Tysvær
I cannot answer whether your syntax could work or not (logically it seems OK, but I guess it could be very time consuming), but I would normally have written your statement like this:

select * from TABLE1 T1 where exists(
select null from Table2 T2 where T1.TABLE1ID in (T2.ID1, T2.ID2))

Alternatively, with Firebird 2.1 you can do something like (I don't use Fb 2.1 yet, so I may have gotten the syntax wrong)

with T2TEMP(ID) as
(select ID1 from TABLE2 union select ID2 from TABLE2)
select * from TABLE1 where TABLE1ID in (select ID from T2TEMP)

or (probably better)

with T2TEMP(ID) as
(select ID1 from TABLE2 union select ID2 from TABLE2)
select TABLE1.* from TABLE1
join T2TEMP on TABLE1.TABLE1ID =T2TEMP.ID)

hth,
Set

-----Original Message-----
From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] On Behalf Of Christian Kaufmann
Sent: 19. januar 2009 13:57
To: firebird-support@yahoogroups.com
Subject: [firebird-support] UNION and IN operator

Hi,

is it not possible to have something like this:

select * from TABLE1 where TABLE1ID in
(select ID1 from TABLE2 union select ID2 from TABLE2)

cu Christian