?
Solved

Mysql Multi Insert from Multi Tables

Posted on 2009-04-09
5
Medium Priority
?
386 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this article, we’ll look at how to deploy ProxySQL.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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