943,901 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 7389
  • MySQL RSS
Jul 13th, 2007
0

Nested insert queries in a single query

Expand 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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
SubeeshBabu is offline Offline
4 posts
since Jul 2007
Jul 15th, 2007
0

Re: Nested insert queries in a single query

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).

SQL Syntax (Toggle Plain Text)
  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.
pty
Reputation Points: 64
Solved Threads: 39
Posting Pro
pty is offline Offline
530 posts
since Oct 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: speed of insert into a MySQL db
Next Thread in MySQL Forum Timeline: Database and web design





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC