Linked Questions
20 questions linked to/from How can I Insert many rows into a MySQL table and return the new IDs?
0 votes
0 answers
264 views
How to get primary key ID of two different tables to automatically insert in another table in Python? [duplicate]
I'm trying to get primary keys from table 1 (patient_id) & table 2 (assessor_id), and insert them automatically into table 3. My HTML code for table 3 isn't working since it requires primary keys ...
0 votes
0 answers
56 views
MySQL - Get LAST_INSERT_ID() of a Mass-Insert [duplicate]
I need to insert a number of rows(~100,000) into a table. The table has one column "Id" that is auto-incremented. LAST_INSERT_ID(); returns the last auto-incremented id of the connection session, but ...
0 votes
0 answers
39 views
return Primary Key ID of ALL rows inserted in a single INSERT statement? [duplicate]
If I run the below INSERT statement and there is an autogenerated primary key called "UserID", would it be possible to get the "UserID" of all rows that were just inserted? INSERT ...
25 votes
4 answers
102k views
How to do multiple inserts in database using spring JDBC Template batch?
I need to insert thousands of records in the database at one go. I am using spring JDBC template in my application. Below is the code I have written so far which executes all inserts at one go. So, ...
26 votes
1 answer
30k views
OUTPUT Clause in MySQL
Is there a way to simulate the OUTPUT clause in MySQL, as we have a OUTPUT clause in SQL Server. Here is the kind of query I have UPDATE employee SET empage = 10 OUTPUT ...
19 votes
1 answer
10k views
Using getGeneratedKeys with batch inserts in MySQL with Connector/J
Using Connector/J, I would like to do a batch insert into a master table followed by a batch insert into a details table (PreparedStatement.executeBatch() for both). I haven't found much information ...
10 votes
4 answers
8k views
MySQL batch insert on multiple tables with LAST_INSERT_ID()
I am trying to insert a lot of users into a MySQL database with two tables: The first table contains the user data. An example INSERT looks like this (id is the primary key, mail is a unique key): ...
4 votes
6 answers
5k views
Can I retrieve the lastInsertId from a bulk insert?
INSERT INTO details (idactivity,user,hours,val,date) VALUES ('981','133','0','10500','2008-07-01'),('981','184','0','2750','2008-07-01'),('981','184','0','2750','2008-07-01') (iddetails as details ...
6 votes
2 answers
6k views
Mysql mulitple row insert-select statement with last_insert_id()
Ok. So the short of it is, I was trying to do an INSERT SELECT such as: START TRANSACTION; INSERT INTO dbNEW.entity (commonName, surname) SELECT namefirst, namelast FROM dbOLD.user; SET @key =...
2 votes
2 answers
4k views
How to batch insert with SimpleJdbcInsert and MapSqlParameterSource?
The followings works, but how can I collect multiple MapSqlParameterSource and insert them all in one batch? new SimpleJdbcInsert(ds).withTableName(TABLENAME); MapSqlParameterSource entry = new ...
-2 votes
2 answers
2k views
Insert multiple rows from a select and put the generated IDs into other table
Given MySQL tables something like this1: alpha ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY , beta_id INT NULL , type_info INT NOT NULL , CONSTRAINT fk_alpha_beta FOREIGN KEY (beta_id) REFERENCES ...
5 votes
0 answers
2k views
MySQL Bulk Insert in Node.js - how to get all insertId's?
I'm currently migrating an old PHP project to Node.js and are now struggeling with the mysqljs/mysql module. I have to execute a bulk insert - so far so good, it works great. But I also need all ...
-2 votes
2 answers
1k views
Getting ids of inserted raws via doctrine dbal
I'm working on a symfony application, and i need to insert multiple raws at once, Doctrine ORM is not a good option because for each raw it will open a connection to execute the query, to avoid this ...
2 votes
0 answers
1k views
how to use pymysql executemany insert many rows and get the ids of each rows
This is a problem in a distribute environment!!! I have processes in many distribute computers, in every process I use pymysql to insert many rows into a table with autoincrease id, I wish I could ...
0 votes
1 answer
758 views
How to detect inserted ids on "insert ignore" statement?
Now,do nothing when "on duplicate key update". So, INSERT IGNORE INTO t1 c1 VALUES(...,...,...); The last_insert_id is only one id at most. Then how to detect multi inserted ids on "insert ignore" ...