Subject Re: [ib-support] alternatives to "where X not in..."
Author Svein Erling Tysvaer
Hi again, Jordi!

select somefields
from sometable
where NOT EXISTS (select * from thistable
WHERE thistable.thistfield = sometable.thisfield)

I expect using NOT EXISTS and NOT IN to be equally fast on Firebird 1.5,
but I must admit that I do not know if Arno has fixed this. Anyway, using
NOT EXISTS has always been a good alternative to using NOT IN.

Set

At 10:27 26.05.2003 +0200, you wrote:
>I found that an SQL statement like:
>
> select somefields
> from sometable
> where thisfield not in (select thistfield from thistable)
>
>is really slow when the tables have a high number of records. So is there
>any better alternative to this? (joins work well when the statement is
>"where X in", but how to do the same in a "not in" case?)