• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 401
  • Last Modified:

Mysql Multi Insert from Multi Tables

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
kingent85
Asked:
kingent85
  • 3
1 Solution
 
Patrick MatthewsCommented:
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
 
bmatumburaCommented:
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
 
kingent85Author Commented:
can you give me an example of a trigger statement?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now