Reputation: 501
I have the following scenario:
I have to import a CSV file to a table. For this i use the LOAD DATA LOCAL INFILE.
Is there a way to retrieve the id's (column 'id') of all inserted rows, since i need them in next step.
Upvotes: 1
Views: 331
Reputation: 121922
Create an BEFORE INSERT or AFTER INSERT trigger and store inserted ID values into another table -
CREATE TRIGGER trigger1
AFTER INSERT
ON table1
FOR EACH ROW
BEGIN
INSERT INTO table2(id) VALUES (NEW.id);
END
Upvotes: 4