Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Situation:
I am trying to delete records that are in three separate tables simultaneously. The database belong to a Veterinary Clinic.I have three tables: tableA, tableB and tableC.
tableA contains the pet's information e.g. pet name, pet age, pet address, pet owner name, breed, PetID
tableB contains data of the pet's visit to the clinic.The pet can have multiple visits. There is a field PetID here that links this table back to tableA
tableC contains data of the pet's medication given out. The pet can have multiple types of medication. Again, there is a field PetID here that links this table back to tableA.
What I want to do:
to delete all records that satisfy the condition : breed = rottweiler (or breed = %weiler) from tableA and tableBWhat I have so far:
DELETE tableA, tableB, tableC FROM tableB, tableC WHERE tableB.PetID = tableC.PetID AND tableA.breed = %weiler AND tableA.date_created < '2009-06-25'Will the SQL query above do what I want it to do? I thought I should get some advice from the experts out there first before I run it so I don't damage the database permanently. By the way, it is an innodb/mysql database.
Thanks for reading my post and helping me. Thank you.

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |