Answer the question
In order to leave comments, you need to log in
How to create an insert into ... select ... on duplicate key update ... query through Laravel Query Builder?
There is a query, something like this (in fact, it is more complicated, a bunch of where and join conditions in the select):
insert into offers (sku, name, availability, price)
select concat(cast(products.id as char), 'ff'),
products.name,
products.availability,
products.price
from products
where products.quantity > 0 &&
products.price > 1000
on duplicate key update name = value(name),
availability = value(availability),
price = value(price);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question