Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
delete records from 3 tables simultaneously
Old 01-13-2011, 04:42 AM delete records from 3 tables simultaneously
Novice Talker

Posts: 9
Name: faizan
Trades: 0
Hello Guyzz,,

I need a help about to delete records simultaneously from 3 different tables in mysql

Here is my 3 tables structure with columns:

Category:
  • catID
  • cat_name

Artists:
  • artID
  • art_name
  • catID
Song:
  • songID
  • s_name
  • artID

What I am trying to do is, when I delete a record from 'category' table, it should delete those artists which have the same catID and then when an artist will be deleted, the songs under that artist which is also going to be deleted, should also deleted.

I can do this for two tables, like when I delete a record from cats table, it will auto delete a record from artists table, but i am confuse in the 3rd table that how can i do this in a single query.

I want to do this all in a single query. I can do this with individuals queries, but like professionals, i want to get all this done in a single query.

Please help me out in learning this.


Thanks in advance
__________________

Please login or register to view this content. Registration is FREE
- Best Rapid Weight Loss Diet Plan

Please login or register to view this content. Registration is FREE
- Number one technical blog
junkyfunky is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-22-2011, 12:11 AM Re: delete records from 3 tables simultaneously
Average Talker

Posts: 23
Trades: 0
Use the following query to delete from all the tables in single query
Code:
DELETE Category, Artists, Song 
FROM Category INNER JOIN Artists INNER JOIN Song 
WHERE Category.CatID = Artists.CatID 
AND Artists.artID = Song.artID
AND catID= ?
__________________

Please login or register to view this content. Registration is FREE
mwasif is offline
Reply With Quote
View Public Profile Visit mwasif's homepage!
 
Reply     « Reply to delete records from 3 tables simultaneously
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14745 seconds with 12 queries