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 362,352 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 4,816 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:
Views: 2065 | 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: 481
Reputation: pty is on a distinguished road 
Rep Power: 3
Solved Threads: 30
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.

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

 

DaniWeb MySQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

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