Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to delete from one table, based on criteria from two tables? 1

Status
Not open for further replies.

as0125

Technical User
Jun 3, 2004
70
0
0
US

Hello all,

I'm having some problems with the following DELETE query:

DELETE TblHistory.*
FROM TblHistory, TblHistoryTemp
WHERE TblHistory.Name = TblHistoryTemp.Name
AND TblHistory.Release = TblHistoryTemp.Release
AND TblHistory.Period = TblHistoryTemp.Period;

When running it, I receive this message: Could not delete from specified tables. I'm a bit new with this, but I'm guessing that SQL doesn't like the way I listed the two tables. All examples I've seen using the "DELETE" command are only for one table. How do I get the query to work based on those criteria?

All help would be greatly appreciated!
Thanks!
 

Hi John,

Based on the thread you recommended, I went back and doubld-checked my tables. Both tables are already indexed using "Autonumber - No duplicates". But I'm still unable to run the delete query.
 
DELETE DISTINCTROW
tblHistory.*

FROM
tblHistory INNER JOIN tblHistoryTemp
ON (tblHistory.Period = tblHistoryTemp.Period)
AND (tblHistory.Release = tblHistoryTemp.Release)
AND (tblHistory.Name = tblHistoryTemp.Name);
 

Thanks for all the help.

The "DELETE DISTINCTROW" did the trick!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top