Results 1 to 2 of 2
2005-10-19, 14:03 #1
- Join Date
- Jan 2001
- Alzano Lombardo, Italy
- Thanked 0 Times in 0 Posts
Delete Query Doesn't Delete (2003)
The Query8 delete query below is supposed to eliminate the records pertaining to the last day in the various database tables
but I get a message saying it's impossible to eliminate the specified tables. What's wrong?
DELETE Previsioni.*, Letture.*, OreFunz.*, Personale.*, Readings.*, Varie.*
FROM ((((Previsioni INNER JOIN Letture ON Previsioni.Giorno = Letture.Giorno) INNER JOIN OreFunz ON Letture.Giorno = OreFunz.Giorno) INNER JOIN Personale ON OreFunz.Giorno = Personale.Giorno) INNER JOIN Readings ON Personale.Giorno = Readings.Giorno) INNER JOIN Varie ON Readings.Giorno = Varie.Giorno
WHERE (((Previsioni.Giorno)=(select max(b2.giorno) from previsioni as B2)));
2005-10-19, 14:10 #2
- Join Date
- Mar 2002
- Thanked 28 Times in 28 Posts
Re: Delete Query Doesn't Delete (2003)
You haven't defined relationships with enforced referential integrity and cascading deletes between the tables. And several tables don't have a primary key.
In general, delete queries on more than one table are tricky. It's best to delete records from the "main" table, and let cascading deletes take care of related records in the other tables.