Delete from table based on query results (1 Viewer)

urobee

Registered User.
Local time
Today, 06:58
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!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:58
Joined
May 7, 2009
Messages
19,229
Code:
DELETE tbl_temp.*
FROM tbl_temp
WHERE [Numbers] IN (SELECT [Numbers] FROM qry_temp );
 

urobee

Registered User.
Local time
Today, 06:58
Joined
Aug 12, 2019
Messages
20
You are awesome, thank You!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:58
Joined
May 7, 2009
Messages
19,229
you're welcome!
 

isladogs

MVP / VIP
Local time
Today, 05:58
Joined
Jan 14, 2017
Messages
18,209
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

Top Bottom