Subject | Re: Outer Joins |
---|---|
Author | Svein Erling |
Post date | 2003-11-13T08:38:39Z |
Hi Tim,
you're right, this is simple and if you've ever used EXISTS you should
have known :o) On the other hand, you described your problem very
well, so it is simple to help you.
SELECT RECORDNO, SEQUENCENUMBER
FROM TABLE1
WHERE NOT EXISTS(
SELECT * FROM TABLE2
WHERE TABLE2.RECORDNO = TABLE1.RECORDNO
AND TABLE2.SEQUENCENUMBER = TABLE1.SEQUENCENUMBER)
Set
you're right, this is simple and if you've ever used EXISTS you should
have known :o) On the other hand, you described your problem very
well, so it is simple to help you.
SELECT RECORDNO, SEQUENCENUMBER
FROM TABLE1
WHERE NOT EXISTS(
SELECT * FROM TABLE2
WHERE TABLE2.RECORDNO = TABLE1.RECORDNO
AND TABLE2.SEQUENCENUMBER = TABLE1.SEQUENCENUMBER)
Set
--- In firebird-support@yahoogroups.com, Tim Ledgerwood wrote:
> Hi all,
>
> I know that this is a simple question, and that I should know the
> answer ... but I don't. *blush*
>
> Given two tables, how do I write a select that will show me all the
> records that are in Table1 but NOT in Table2?
>
> CREATE TABLE TABLE1
> (
> RECORDNO INTEGER NOT NULL,
> SEQUENCENUMBER INTEGER,
> PRIMARY KEY(RECORDNO)
> );
>
> CREATE TABLE TABLE2
> (
> RECORDNO INTEGER NOT NULL,
> SEQUENCENUMBER INTEGER,
> PRIMARY KEY(RECORDNO)
> );
>
> In this example, assume that I want to find all of the records in
> Table1 where there is no matching record in Table2.
>
> Thanks in advance,
>
> Tim