Avatar of ExpExchHelp
ExpExchHelp
Flag for United States of America asked on

Simple Delete Query

I'm trying to figure out how to create a simple DELETE query in Access.

Assuming we have two structurally identical tables, I want to delete records (from Table A) that exist in both Table A and Table B.

See attached JPG for a basic example (where records 89 and 17 should be deleted from Table A).

I chose the following SQL but it results in an error "Specify the table containing the records you want to delete).

DELETE TableA.Field1
FROM TableA INNER JOIN TableB ON TableA.Field1 = TableB.Field1
WHERE (((TableA.Field1)=(SELECT TableA.Field1 FROM TableA INNER JOIN TableB ON TableA.Field1 = TableB.Field1;)));


What's the proper syntax?

Thanks,
EEH
Example.jpg
Microsoft Access

Avatar of undefined
Last Comment
aikimark

8/22/2022 - Mon
mbizup

For access the first  line shoud just be

DELETE *
ramrom

delete from tablea where field1 in (select field1 from tableb)
ASKER CERTIFIED SOLUTION
Rey Obrero (Capricorn1)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
aikimark

DELETE TableA.*
FROM TableA INNER JOIN TableB ON TableA.Field1 = TableB.Field1

Open in new window

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck