当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Retrieving ID's of imported CSV (LOAD DATA INFILE)

问题描述:

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.

网友答案:

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
分享给朋友:
您可能感兴趣的文章:
随机阅读: