delete query with 2 tables

  • Thread starter Thread starter bsacks
  • Start date Start date
B

bsacks

I have a query that has 2 tables linked (one to many). Access won’t let me
create a delete query from this – it give me a message that I need to choose
the table to delete from. Can you help me?

I am an intermediate user - I do not know SQL.

thanks,

Brandy
 
bsacks said:
I have a query that has 2 tables linked (one to many). Access won’t let me
create a delete query from this – it give me a message that I need to choose
the table to delete from. Can you help me?

I am an intermediate user - I do not know SQL.

thanks,

In your Relationship between the two, you should have Cascade Deletes turned on.
Then you make the Delete query from the One side table only. The related records
in the Many side will be deleted automatically.

Tom Lake
 
I have a query that has 2 tables linked (one to many). Access won’t let me
create a delete query from this – it give me a message that I need to choose
the table to delete from. Can you help me?

I am an intermediate user - I do not know SQL.

thanks,

Brandy

You need to be sure you only specify one table in the DELETE clause. In the
query grid, there should be one or more fields with "From" and one or more
other fields with "Where" - select the * pseudo-field from the table from
which you want to delete records in the FROM column, and put any fields from
the other table in the WHERE column(s).

The SQL view of the query would resemble

DELETE TableA.*
FROM TableA INNER JOIN TableB
ON <whatever>
WHERE TableB.field = something

If this doesn't help, please open the Delete query; select View... SQL; and
post the SQL text here.
 
Tom Lake said:
In your Relationship between the two, you should have Cascade Deletes turned on.
Then you make the Delete query from the One side table only. The related records
in the Many side will be deleted automatically.

Tom Lake
Hi Tom,

Thanks for the reply. I have turned Cascade Delete on. How (exactly) do i
make the delete query from one side table only?

thanks!
 

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

Back
Top