Friday, 5 May 2017

Getting last id when inserting several rows

I'm using nodeJS and mysql to insert a few rows in my database. Here is my code:

 connection.query('INSERT INTO trainings (file_id, selection_start, selection_end, label_id) VALUES ?', [toInsert], function(err, results){
...
    }

As you can see I'm inserting several rows at a time. How can I get all the inserted id if my table is in autoIncrement?

results.insertId only returns one ID (and not all)

Any idea on how I could fix that?



via Vico

No comments:

Post a Comment