I changed my tables to use foreign key constraints with on delete cascade
and that did what I needed.

Thanks,

David Ruggles
CCNA MCSE (NT) CNA A+
Network Engineer        Safe Data, Inc.
(910) 285-7200  [EMAIL PROTECTED]



-----Original Message-----
From: David Ruggles [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 18, 2008 11:51 AM
To: 'mysql'
Subject: Multi-table deletes


My SQL:

delete c, gt, g, sp
from Companies as c,
        GroupTypes as gt,
        Groups as g,
        ServicePersons as sp
where gt.companyuid = c.uid
        and g.companyuid = c.uid
        and sp.companyuid = c.uid
        and c.id = '01'

This works fine as long as there are records in all tables, but if one of
the tables doesn't have any records then the whole delete won't delete any
records.

I'm trying to clean up all records related to a specific company. Would it
be better to do something like this with triggers?

Thanks,

David Ruggles
CCNA MCSE (NT) CNA A+
Network Engineer        Safe Data, Inc.
(910) 285-7200  [EMAIL PROTECTED]



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
No virus found in this incoming message.
Checked by AVG - http://www.avg.com 
Version: 8.0.138 / Virus Database: 270.5.1/1560 - Release Date: 7/18/2008
6:47 AM



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to