SQL Query to fetch not matching records [message #650722] |
Mon, 02 May 2016 04:28 |
pstanand
Messages: 133 Registered: February 2005 Location: Chennai,India
|
Senior Member |
|
|
Hi,
I have a table table_A and table_B.
Both have two columns material_number and language_code which is composite primary key.
The table_A has 1.5 million records and table_B has short of 6 records to 1.5 million.
I want to find out the missing 6 records using these tables.
How do I achieve this? Is NOT EXISTS will work?
kindly suggest me.
thanks.
Regards,
pstanand.
|
|
|
|
|
Re: SQL Query to fetch not matching records [message #650731 is a reply to message #650724] |
Mon, 02 May 2016 07:43 |
Bill B
Messages: 1971 Registered: December 2004
|
Senior Member |
|
|
and if you wanted to put the missing records into table_b you could do the following
INSERT INTO TABLE_B
SELECT * FROM TABLE_A
WHERE (MATERIAL_NUMBER,LANGUAGE_CODE) IN
(SELECT material_number, language_code FROM table_A
MINUS
SELECT material_number, language_code FROM table_B);
|
|
|
|
|