Subject Re: SQL Question - "Not In" Query
Author ra8009
Thanks for the tip. Do you mean that the syntax you suggested is more
efficient? Is that becuase my syntax will first perform the join and
then narrow it down to just the ones that are NULL?

--- In firebird-support@yahoogroups.com, Alexandre Benson Smith
<iblist@t...> wrote:
> 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