Solved

Mysql Multi Insert from Multi Tables

Posted on 2009-04-09
5
353 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
  • 3
5 Comments
 
LVL 92

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

Expert Comment

by:bmatumbura
ID: 24107871
0
 
LVL 11

Accepted Solution

by:
bmatumbura earned 500 total points
ID: 24107912
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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 …

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now