You can try:
SELECT m.num1, m.num2 FROM MASTER m LEFT OUTER JOIN MINOR i ON m.num1=i.num1 AND m.num2=i.num2 WHERE i.num1 IS NULL and i.num2 IS NULL
Main Topics
Browse All TopicsI am looking for the best (fastest/less-resource-int
TABLE MASTER
--num1-- --num2--
1 3
1 6
2 5
3 4
3 8
3 16
TABLE MINOR
--num1-- --num2--
1 3
3 8
If this were a simple task of determining which records in the MASTER table did not exist in the MINOR table based on one key then the following query (as one method) would work:
SELECT num1, num2 FROM MASTER WHERE num1 NOT IN (SELECT num1 FROM MINOR);
However, I want to omit records from MASTER where num1 AND its associated num2 value appear in the MINOR table. For example, the desired dataset would look like:
RESULTS AFTER COMPARE
--num1-- --num2--
1 6
2 5
3 4
3 16
Currently I am having to run one query to pull results from the MASTER table, then run another query to get results from the MINOR query, then loop through the resultsets to compare the num1 AND num2 values. While this works, it is very slow, especially when dealing with large datasets. Any ideas?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: RoonaanPosted on 2005-02-04 at 03:38:18ID: 13224401
Would you test with the LEFT Join query below for me?
SELECT
ma.num1, ma.num2
FROM
`MASTER` as ma
LEFT JOIN
`MINOR` as mi
ON
mi.num1 = ma.num1 AND mi.num2 = ma.num2
WHERE
mi.num1 IS NULL
In am not sure only wether or not the 'AND' is allowed in the ON clause.
Kind regards
-r-