Unmatched Query

L

Les

Is it possible to create an unmatched query without having a primary key or a
field to uniquely identify each record?

Thanks.
 
J

John Spencer

You have to have some way to identify which records should match which
records - that can be multiple fields and does not have to include a primary
key.

For example the following would work.
SELECT A.*
FROM SomeTable as A LEFT JOIN AnotherTable As B
ON A.LastName = B.LastName
AND A.FirstName = B.FirstName
AND A.ZipCode = B.ZipCode
WHERE B.LastName is Null

There might be problems in records being returned where there is a match if
any of the fields can be null. For instance if ZIPCode is null in both
records and the name fields match you will still get the A.Record returned
as a non-match. That can be handled by changing the join to force values in
the fields where nulls are present. Something like the following:

SELECT A.*
FROM SomeTable as A LEFT JOIN AnotherTable As B
ON A.LastName & "" = B.LastName & ""
AND A.FirstName & "" = B.FirstName & ""
AND A.ZipCode & "" = B.ZipCode & ""
WHERE B.LastName is Null




--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top