excluding...

excluding...

am 24.05.2006 09:03:36 von KrunoG

Hi,

I have a "simple" problem:

From the table "A" I have to exclude phone numbers present in table "B" and
those numbers that are also in the table "C"

So far I've used this sql that works only in A-B but I would like to have C
here aswell:
select o.PHONE
from B b, A a, C c
where b.phone(+)=a.phone
and b.phone is null

Re: excluding...

am 24.05.2006 09:22:41 von KrunoG

> select a.PHONE

Re: excluding...

am 24.05.2006 11:19:41 von zac.carey

Assuming you can use nested SELECTs then I think this syntax would
work...

SELECT DISTINCT(table_a.string) from table_a WHERE table_a.string NOT
IN (SELECT DISTINCT(string) FROM table_b) AND table_a.string NOT IN
(SELECT DISTINCT(string) FROM table_c);

Re: excluding...

am 24.05.2006 11:45:31 von Sandy

If u can use union even this would work :
SELECT phone
FROM a
WHERE phone NOT
IN (
SELECT phone
FROM c
UNION SELECT phone
FROM b
)

strawberry wrote:
> Assuming you can use nested SELECTs then I think this syntax would
> work...
>
> SELECT DISTINCT(table_a.string) from table_a WHERE table_a.string NOT
> IN (SELECT DISTINCT(string) FROM table_b) AND table_a.string NOT IN
> (SELECT DISTINCT(string) FROM table_c);