Nested insert queries in a single query

Reply

Join Date: Jul 2007
Posts: 4
Reputation: SubeeshBabu is an unknown quantity at this point 
Solved Threads: 0
SubeeshBabu's Avatar
SubeeshBabu SubeeshBabu is offline Offline
Newbie Poster

Nested insert queries in a single query

 
0
  #1
Jul 13th, 2007
hi ,
I have four different tables, all are linked together using foreign key relationships.
Now i need to insert data in to the tables.How can i use nested insert queries to insert data by a single query?
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 521
Reputation: pty is on a distinguished road 
Solved Threads: 37
pty's Avatar
pty pty is offline Offline
Posting Pro

Re: Nested insert queries in a single query

 
0
  #2
Jul 15th, 2007
Originally Posted by SubeeshBabu View Post
hi ,
I have four different tables, all are linked together using foreign key relationships.
Now i need to insert data in to the tables.How can i use nested insert queries to insert data by a single query?
I suggest using transactions (you need the InnoDB storage engine for this).

  1. START TRANSACTION
  2. INSERT INTO blah...
  3. INSERT INTO blah...
  4. COMMIT

If one of your statements causes an error none will be committed so you won't get corrupted data / missing keys etc.
Note to self... pocket cup
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC