Update Query

S

Steven

I have a "Table1" with 1 field "Category" with 22 records. The records are
unique.

I have "Table2" with 20 fields and 10,000 records. One of its fields is
"Category".

I want to delete the records in "Table2" where the Category is not found in
"Table1"

I tried some queries but it says "Must be an updateable query".

Can this be done?

Thank you,

Steven
 
S

Steven

This is me again.

I notice it works for what I want if they are both tables.

What if the "Table1" with 1 field "Category" 22 records is actually a query
"Query1" of a table getting the unique "Category" records.

Can it still be used in an update query? Thats when I run into a problem.

Thank you,

Steven
 
J

John W. Vinson

I have a "Table1" with 1 field "Category" with 22 records. The records are
unique.

I have "Table2" with 20 fields and 10,000 records. One of its fields is
"Category".

I want to delete the records in "Table2" where the Category is not found in
"Table1"

I tried some queries but it says "Must be an updateable query".

Can this be done?

Thank you,

Steven

Try a subquery:

DELETE * FROM Table2
WHERE CATEGORY NOT IN(SELECT Category FROM Table1);
 
J

John W. Vinson

What if the "Table1" with 1 field "Category" 22 records is actually a query
"Query1" of a table getting the unique "Category" records.

Can it still be used in an update query? Thats when I run into a problem.

No, because no DISTINCT query is ever updateable.

Perhaps you could post the SQL of the two queries.
 

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