excluding...

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
KrunoG [ Mi, 24 Mai 2006 09:03 ] [ ID #1331139 ]

Re: excluding...

> select a.PHONE
KrunoG [ Mi, 24 Mai 2006 09:22 ] [ ID #1331140 ]

Re: excluding...

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);
zac.carey [ Mi, 24 Mai 2006 11:19 ] [ ID #1331141 ]

Re: excluding...

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);
Sandy [ Mi, 24 Mai 2006 11:45 ] [ ID #1331142 ]
PHP » alt.php.sql » excluding...

Vorheriges Thema: checkbox + columns
Nächstes Thema: Please Help! Can't connect to remote MySQL server using PHP