Solved

Mysql Multi Insert from Multi Tables

Posted on 2009-04-09
5
360 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

803 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