User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 423,552 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,919 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 2631 | Replies: 1
Reply
Join Date: Jul 2007
Posts: 3
Reputation: SubeeshBabu is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
SubeeshBabu's Avatar
SubeeshBabu SubeeshBabu is offline Offline
Newbie Poster

Help Nested insert queries in a single query

  #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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2005
Location: Manchester, UK
Posts: 482
Reputation: pty is on a distinguished road 
Rep Power: 3
Solved Threads: 33
pty's Avatar
pty pty is offline Offline
Posting Pro in Training

Re: Nested insert queries in a single query

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MySQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 6:10 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC