Subject Re: [firebird-support] Re: The First to select
Author Ann W. Harrison
I wrote: >
>>A slightly more conventional version would be
>>
>>select 1
>> from rdb$database
>> where exists (select 1
>>from <table>
>>where <field> is NULL)
>>
>>
>>Either is exactly a full table scan if the field is never null, but
>>less than that if the field can be null.

I meant that it stops if any field is null.

>
> In what way is [that] > any better than just
>
> select 1 from <table> where <field> is NULL
>

Rdb$database is a table known to have exactly one row. The where
exists will stop when it finds the first null. Your syntax will
read the whole table, returning a series of 1's. Our "first" syntax
is unique to us. So, for that matter is rdb$database. However
many databases offer some table that is guaranteed to have exactly
one row.

Regards,


Ann