The following will give you all the records in table1 that do not exist
in table two:

select a.key, a.description from table1 a
exception join table2 b using (key);

further, this will copy the missing records from table1 into table2

insert into table2 (
select a.key, a.description from table1 a
exception join table2 b using (key)
)


Coy Krill
Systems Analyst
Whidbey Island Bank


-----Original Message-----
From: java400-l-bounces+coyk=wibank.com@xxxxxxxxxxxx
[mailto:java400-l-bounces+coyk=wibank.com@xxxxxxxxxxxx] On Behalf Of
Ashish Kulkarni
Sent: Wednesday, July 25, 2007 13:58
To: java400-l@xxxxxxxxxxxx
Subject: SQL question

Hi
I have 2 tables which has similar structure, i want to
write a sql statement to compare the 2 tables and find
the missing keys from one
For example
Table 1
Key Description
001 This is one
002 This is two

Table 2
Key Description
001 this is one

Now i want to write a query to find out, 002 is
missing in table 2, and may be a query to insert 002
into table2
Any ideas?

Ashish

A$HI$H




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.