Gerhardpet
asked on
Need help with Access query to delete records
I have 2 tables in Access and in Table1 I want to find records without matching records in Table2 and then delete them from Table1.
Below I have a query that will find records in ADDRESS table without matching records in LOCAL_ADDRESS table. Now all I need to know how I could get the same query to delete unmatched records in the ADDRESS table.
Can anyone help me with this?
Below I have a query that will find records in ADDRESS table without matching records in LOCAL_ADDRESS table. Now all I need to know how I could get the same query to delete unmatched records in the ADDRESS table.
Can anyone help me with this?
SELECT ADDRESS.RECORD_TYPE, ADDRESS.CEV_NO, ADDRESS.ADDR_TYPE, ADDRESS.ID, ADDRESS.NAME
FROM ADDRESS LEFT JOIN LOCAL_ADDRESS ON (ADDRESS.ID = LOCAL_ADDRESS.ID) AND (ADDRESS.ADDR_TYPE = LOCAL_ADDRESS.ADDR_TYPE) AND (ADDRESS.RECORD_TYPE = LOCAL_ADDRESS.RECORD_TYPE) AND (ADDRESS.[CEV_NO] = LOCAL_ADDRESS.[CEV_NO])
WHERE (((LOCAL_ADDRESS.CEV_NO) Is Null));
ASKER
I think your idea will work but in my table all following fields are indexed. Meaning that the ID field could be the same value for 2 records but the same 2 records would not have the same value for CEV_NO. Can you give me an idea who I could make it work with all my indexed fields?
Indexed fields:
Indexed fields:
RECORD_TYPE
CEV_NO
ADDR_TYPE
ID
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That works perfect! Now I want the same query to work in Navicat but it does not.
I know that I did not mention this in the original question so I will post another question and award points to you.
Thank you very much for your help and perhaps you can help me out with my other questions too.
I know that I did not mention this in the original question so I will post another question and award points to you.
Thank you very much for your help and perhaps you can help me out with my other questions too.
ASKER
Open in new window