Subject Re: [firebird-support] select in (subquery)
Author Lester Caine
Mauricio I Magni wrote:

>>select , p.Nombre
>> from Personas p
>> where EXISTS(
>> SELECT select 1 from Beneficiarios b
>> WHERE p.Persona_id = b.Persona_id
>> and b.Beneficiario_Titular_Id = :Titular_ID
>> )

Am I missing something when I ask - Why not use the sub-select as the
main query - to give you a list of Persona_id records you are interested
in, and then JOIN to Personas to provide the additional fields?

I use this all the time to provide caller details from a large table
into a short sub list of interesting records.

SELECT b.Persona_id
, p.Apellido
, p.Nombre
from Beneficiarios b
JOIN Personas p ON p.Persona_id = b.Persona_id
WHERE b.Beneficiario_Titular_Id = :Titular_ID

I'm returning several records from 500,000 in no time at all.

--
Lester Caine
-----------------------------
L.S.Caine Electronic Services