Subject Re: [firebird-support] SQL Question - "Not In" Query
Author Alexandre Benson Smith
ra8009 wrote:

>If I have customers and orders, how do I find the customers with no
>orders? Is the methos that I'm using below accurate and the best way?
>
>SELECT *
>FROM CUSTOMERS C LEFT OUTER JOIN ORDERS O ON
>C.CUST_ID = O.CUST_ID
>WHERE O.CUST_ID IS NULL
>
>
Your statement will work, but you will get a lot of records for
customers that have more than one order posted.

try this one:

select
*
from
Customers C
where
not exists (select 1 from Orders O where O.Cust_ID = C.Cust_ID)


see you !

--

Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br