Re: help with multi-table query
Posted in 1993
Topics: Triggers, Constraints & Referential Integrity
rickt@sapphire.zed.com (Rickey Thomas Tom) writes:
>I hope someone out there can solve the following problem
>I have two tables
>table1 table2
> lastName firstName lastName
> tom doug tom
> john doug john
> jackson mathew john
> wilson
>I need an SQL statement which will
>1) fetch all lastnames from table1 WHICH ARE NOT in Table2 and the firstname is
> doug
>Such a query, when applied to the above will return a list from table1 which
>include jackson, wilson. The lastname fields are foreign keys.
SELECT lastName FROM table1
WHERE lastName NOT IN
(SELECT lastName FROM table2
WHERE firstName = "doug")
---
Frank Munkert | Uni Erlangen-Nuernberg
Zum Froschbruecklein 5 |
8500 Nuernberg 10 | <fkmunker@cip.informatik.uni-erlangen.de>
Germany | or: <ln_fmu@pki-nbg.philips.de>