Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to get a list of inserted record in a table

Posted on 2009-04-11
2
Medium Priority
?
284 Views
Last Modified: 2012-08-13
I am trying to get a list of all the inserted records into a table. The records that are getting inserted  into the current table is via a select query that groups records from another table and inserts them into the current table.

Once I get all the newly inserted record I want to insert them into a 3 table.



0
Comment
Question by:busapps
2 Comments
 
LVL 21

Accepted Solution

by:
K V earned 1500 total points
ID: 24124769
"I am trying to get a list of all the inserted records into a table. " >>>select * from TABLE-NAME;

"The records that are getting inserted  into the current table is via a select query that groups records from another table and inserts them into the current table." >>> You mean you're doing something like
INSERT INTO TABLE2 SELECT  * FROM TABLE1; ?????

"Once I get all the newly inserted record I want to insert them into a 3 table." >> Does this mean you already have record in TABLE2 and you just want to insert newly added records to be taken to these three tables???

You may use LOAD DATA FILE  or the same INSERT INTO command with appropriate where condition.

Your Question Is Not Clear.
0
 
LVL 14

Expert Comment

by:racek
ID: 24124858
USE INSERT TRIGGER
http://dev.mysql.com/doc/refman/5.1/en/create-trigger.html
delimiter |
 
CREATE TRIGGER yourTrigger AFTER INSERT ON tab1
  FOR EACH ROW BEGIN
    INSERT INTO table2 SET col1 = NEW.co1, col2 = NEW.co2;
    INSERT INTO table3 SET col1 = NEW.co1, col2 = NEW.co2;
  END;
|

Open in new window

0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month7 days, 11 hours left to enroll

824 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