Unix Technical Forum

Multi-table deletes

This is a discussion on Multi-table deletes within the MySQL General forum forums, part of the MySQL category; --> My SQL: delete c, gt, g, sp from Companies as c, GroupTypes as gt, Groups as g, ServicePersons as ...


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-22-2008, 06:56 AM
David Ruggles
 
Posts: n/a
Default 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 david@safedatausa.com


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:43 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com