Delete from table based on query results

urobee

Registered User.
Local time
Today, 11:23
Joined
Aug 12, 2019
Messages
20
Hy!

I have a table (tbl_temp) with some columns and a query (qry_temp).
The query (qry_temp) get data from the table (tbl_temp) based on some criteria.
I would like to delete the records of qry_temp from tbl_temp.

I've tried to make an SQL but it's delete all of the records from tbl_temp not just the ones from the qry_temp.

Code:
DELETE tbl_temp.*
FROM tbl_temp
WHERE EXISTS (SELECT * FROM qry_temp WHERE qry_Temp.[Numbers] = tbl_temp.[Numbers]);

Please help me in this case. Thanks!
 
Code:
DELETE tbl_temp.*
FROM tbl_temp
WHERE [Numbers] IN (SELECT [Numbers] FROM qry_temp );
 
You are awesome, thank You!
 
you're welcome!
 
Here's another method which I think is simpler:
Code:
DELETE DISTINCTROW tbl_temp.*
FROM tbl_temp
INNER JOIN qry_Temp.[Numbers] = tbl_temp.[Numbers];
 

Users who are viewing this thread

Back
Top Bottom