Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Mysql Multi Insert from Multi Tables

Posted on 2009-04-09
5
Medium Priority
?
393 Views
Last Modified: 2013-12-12
How can I write a mysql query that will insert into multiple tables from multiple tables. I know that you can select multiple tables and insert into a single one. I am trying to duplicate a customer that has an id in all of my tables. I simply want to make a copy of this customer data and update another customer. So the only thing changing is the ID.
0
Comment
Question by:kingent85
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 24107158
kingent85 said:
>>How can I write a mysql query that will insert into multiple tables from multiple tables.

You can't.  A single INSERT statement will only insert into one table.  You need to execute a separate
statement for each table you want to insert into.
0
 
LVL 11

Expert Comment

by:bmatumbura
ID: 24107243
You can also use an INSERT Trigger on the table in which you are inserting the records. The trigger will then have to insert these new values into the additional tables
0
 

Author Comment

by:kingent85
ID: 24107575
can you give me an example of a trigger statement?
0
 
LVL 11

Accepted Solution

by:
bmatumbura earned 1500 total points
ID: 24107912
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question