2

I have table

users

id name
1 One
2 two

I want to insert multiple data in this table with

const query = `INSERT INTO users (`name`) VALUES("three"), ("four")`;

now I used this with any npm module like:

const result = await SQL.query(query);

then it returns only 4 but I want [3,4] (auto incremented Id) (and wants all new inserted data's id like 3 and four currently it returns only 4) how can I archive this

Dhaval
  • 868
  • 12
  • 22
  • 1
    Don't you know `ref` in advance when putting it into DB? – Justinas Feb 19 '21 at 09:18
  • Sorry @Justinas ref is actually primary id of table – Dhaval Feb 19 '21 at 09:21
  • Does this answer your question? [How can I Insert many rows into a MySQL table and return the new IDs?](https://stackoverflow.com/questions/7333524/how-can-i-insert-many-rows-into-a-mysql-table-and-return-the-new-ids) – Darth Feb 19 '21 at 10:48

0 Answers0