Subject Re: [firebird-support] Using EXISTS instead COUNT(*)
Author Magnus Titho
buppcpp wrote:
> I read in the Firebird book to use EXISTS instead of SELECT COUNT(*)... If
> you just need to see if a record exist.
>
select t1.id from table1 t1
where (select count(*) from table2 t2 where t2.foreignkey = t1.id) > 0

==>

select t1.id from table1 t1
where exists(select t2.id from table2 t2 where t2.foreignkey = t1.id)


--
Magnus