You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[x ] latest
[ ] @next
[ ] 0.x.x (or put your version here)
Steps to reproduce or a small repository showing the problem:
-- Insert a new record into orders and obtain the new order IDINSERT INTO orders (created_on, customer_id, shipping_id, tax_id) VALUES
(NOW(), inCustomerId, inShippingId, inTaxId);
-- Obtain the new Order IDSELECT LAST_INSERT_ID() INTO orderId;
-- Insert order details in order_detail tableINSERT INTO order_detail (order_id, product_id, attributes,
product_name, quantity, unit_cost)
SELECT orderId, p.product_id, sc.attributes, p.name, sc.quantity,
COALESCE(NULLIF(p.discounted_price, 0), p.price) AS unit_cost
FROM shopping_cart sc
INNER JOIN product p
ONsc.product_id=p.product_idWHEREsc.cart_id= inCartId ANDsc.buy_now;
Reacted by I V, lueenavarro, Henrique Spadim, Artur Klesun, JM, Vicary, Livan, Anthony Rosequist, Aleksandr Rzhanitsyn, Fernando Rosentalski and 4 more
One of the way, I could find is via query runner. In my case, I was supposed to insert more than 700K records into destination table from source view. My destination table was also rapidly changing and caused integrity constraint violation. so sharing the complete solution in case it make sense to others.
awaitrepository.createQueryBuilder("<repo name alias>").insert().into(EntityName,[...columns]).select([...columns]).from(EntityName,"<repo name alias>").where({...whereClause}).printSql().execute()
and it completely dropped the INSERT INTO part and just ran the SELECT
Reacted by Juliano Bazzi, jmichaelterenin, Simon, Arvo Bendi, Ahmed, Aleksandr Rzhanitsyn, Rajeev Radhakrishnan, Vicary, Marc Beaupre, Fernando Rosentalski and 6 more
TypeORM has returned to active development after recently transitioning to new leadership (see related announcement).
As part of the new team's efforts to prioritise work on the project moving forward, it is necessary to clean up the backlog of stale issues.
🧹 This issue is being automatically closed because it has had no activity in the last 6 months.
If you believe this issue is still relevant, feel free to comment below and the maintainers may reopen it. Thank you for your contribution.
Activity
codebarn4ajay commentedon Oct 18, 2019
One of the way, I could find is via query runner. In my case, I was supposed to insert more than 700K records into destination table from source view. My destination table was also rapidly changing and caused integrity constraint violation. so sharing the complete solution in case it make sense to others.
ivid commentedon Nov 5, 2019
Any update on this?
Aside from doing a raw query, could not find any way to achieve this (INSERT INTO SELECT statement).
lueenavarro commentedon Apr 18, 2020
+1 on this, I want to get away with raw queries as much as possible
ryegye24 commentedon Mar 22, 2021
+1 I tried just doing
and it completely dropped the INSERT INTO part and just ran the SELECT
unkindypie commentedon Feb 23, 2022
Still relevant
github-actions commentedon Sep 18, 2025
TypeORM has returned to active development after recently transitioning to new leadership (see related announcement).
As part of the new team's efforts to prioritise work on the project moving forward, it is necessary to clean up the backlog of stale issues.
🧹 This issue is being automatically closed because it has had no activity in the last 6 months.
If you believe this issue is still relevant, feel free to comment below and the maintainers may reopen it. Thank you for your contribution.
Moustafa3attia commentedon Mar 16, 2026
Still relevant