Subject Re: [firebird-support] Optimizing subquery in WHERE ..
Author Douglas Tosi
On Tue, Feb 10, 2009 at 11:48 AM, Harriv <harriv@...> wrote:
> However I'd like to have subquery on where:
> SELECT field1
> FROM table1
> where field2 in (SELECT first 2 fieldA from table2 where fieldB = 1)

Just guessing, but try:

select field1
from table1
inner join (SELECT first 2 fieldA from table2 where fieldB = 1) t2 on
t2.fieldA=table1.field2

This should be faster if fields table1.fieldA and table2.fieldB are indexed.

hth,
--
Douglas Tosi
www.sinatica.com