Computing.Net > Forums > Database > cross table delete

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

cross table delete

Reply to Message Icon

Name: gizmoconcept
Date: July 3, 2009 at 04:47:49 Pacific
OS: Windows XP
Product: Mysql / Mysql
Subcategory: MySQL
Comment:

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 tableB

What 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.



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: cross table delete

Switchboard manager access 2007 www.computing.net/answers/dbase/switchboard-manager-access-2007/390.html

MySQL Select multiple tables www.computing.net/answers/dbase/mysql-select-multiple-tables/158.html

Deleting Duplicates in MS Access www.computing.net/answers/dbase/deleting-duplicates-in-ms-access/280.html