1

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.

Michael Grenzer
  • 503
  • 1
  • 9
  • 20

1 Answers1

4

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
Devart
  • 119,203
  • 23
  • 166
  • 186