Subject Re: [IBO] Problem setting filter to TIB_Query
Author Svein Erling Tysvær
(sorry if this is a duplicate posting, something unusual happened just
as I was posting).

--- In IBObjects@yahoogroups.com, "Antti Kurenniemi" wrote:
> Hi all,
>
> I have a customers table, where customers can have any number of
> classifications (customer classes). This is done by having the
> classes in another table, and a connector table CustToClass with
> fields custid and classid. To get a list of all customers belonging
> to given classes, I would do something like:
>
> SELECT id, name FROM customer WHERE id IN
> (SELECT custid FROM custtoclass WHERE classid IN (1, 2, 3))
>
> Performance issues aside (though let me have it if this is all nuts,
> I'm willing to learn ;-), this works.

Sure, it is possible to do things this way, but I generally prefer

SELECT c.id, c.name
FROM customer c
WHERE EXISTS(SELECT * from custtoclass ctc
WHERE ctc.custid = c.id AND ctc.classid IN (1, 2, 3))

I normally find performance to be excellent with EXISTS. I don't use
filters with IBO, but would expect it to work.

HTH,
Set