• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4309
  • Last Modified:

MINUS (set diff.) operator in Access query

I have to retrive records from a table that are not present in another table with the same schema.  But I am working with access database and as much I know it doesn't support MINUS operator.  I use following sql query instead.

SELECT name FROM ref  WHERE not exists (SELECT name FROM glossary WHERE ref.name=glossary.name)

ref has 6571 records
glossary has 11315 records

It's extremely slow.  It took about 2'48'' to return 124 records on a PIII 866 machine.

Is there any other good way?

Thanks in advance.

Jerry
0
Jerryleo
Asked:
Jerryleo
1 Solution
 
nathanielSystem Applications DeveloperCommented:
say you have a ref table with (ID, name, file)
and glossary table (ID, name, page)

the faster way to identify is like this example:

SELECT ref.name, FROM ref LEFT JOIN glossary ON ref.ID = glossary.ID
WHERE (glossary.name) Is Null;

this will display all the names from ref table that are not found in glossary table, based on their ID. You can also use the 'name' in joining, instead of their IDs.

hope that helps

0
 
JerryleoAuthor Commented:
Thank you very much

It works great. It only took 0.5' on my PIII 866 machine.

Best Regard

Jerry
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now