I have an Access 2000 mailing list database with the following tables:
Table Addresses
Primary key AddressID (autonumber)
Table Contacts
Primary key ContactID (autonumber)
Field MailingAddressID (Long, FK to Addresses)
The relationship from Addresses to Contacts is one-to-many with RI enforced and deletes cascading (but not updates).
There is a record in Addresses (AddressID=332) that has no related records in Contacts. I have verified this both via the Addresses subdatasheet, and by sorting Contacts by MailingAddressID and scanning the list.
The following query, however, fails to find this record:
SELECT Addresses.AddressID, Addresses.DeliveryAddress, Addresses.City, Addresses.StateProv, Addresses.PostalCode, Addresses.Country
FROM Addresses
WHERE (((Addresses.AddressID) Not In (SELECT MailingAddressID FROM Contacts)));
I added a fresh Addresses row with no Contacts row, and it doesn't find that either!
I tried using an outer join instead:
SELECT Addresses.AddressID, Addresses.DeliveryAddress, Addresses.City, Addresses.StateProv, Addresses.PostalCode, Addresses.Country, Contacts.ContactID
FROM Addresses LEFT JOIN Contacts ON Addresses.AddressID = Contacts.MailingAddressID
WHERE (((Contacts.ContactID) Is Null));
This found the rows. I selected the rows and pressed the Delete key. I got the confirmation dialog and OK'd it, and was left with an empty recordset displayed. But when I close the query and reopen it, the rows are back--they weren't deleted at all, and I didn't get any error message.
Anybody know what's going on here? Rick Sprague
Table Addresses
Primary key AddressID (autonumber)
Table Contacts
Primary key ContactID (autonumber)
Field MailingAddressID (Long, FK to Addresses)
The relationship from Addresses to Contacts is one-to-many with RI enforced and deletes cascading (but not updates).
There is a record in Addresses (AddressID=332) that has no related records in Contacts. I have verified this both via the Addresses subdatasheet, and by sorting Contacts by MailingAddressID and scanning the list.
The following query, however, fails to find this record:
SELECT Addresses.AddressID, Addresses.DeliveryAddress, Addresses.City, Addresses.StateProv, Addresses.PostalCode, Addresses.Country
FROM Addresses
WHERE (((Addresses.AddressID) Not In (SELECT MailingAddressID FROM Contacts)));
I added a fresh Addresses row with no Contacts row, and it doesn't find that either!
I tried using an outer join instead:
SELECT Addresses.AddressID, Addresses.DeliveryAddress, Addresses.City, Addresses.StateProv, Addresses.PostalCode, Addresses.Country, Contacts.ContactID
FROM Addresses LEFT JOIN Contacts ON Addresses.AddressID = Contacts.MailingAddressID
WHERE (((Contacts.ContactID) Is Null));
This found the rows. I selected the rows and pressed the Delete key. I got the confirmation dialog and OK'd it, and was left with an empty recordset displayed. But when I close the query and reopen it, the rows are back--they weren't deleted at all, and I didn't get any error message.
Anybody know what's going on here? Rick Sprague