I want to update n number of records in table using a query like below, but it will return an error since in mysql, it is not allowed to use value after the limit key

update producedItem pi 
inner join productionOrderLine pol on pol.id = pi.productionOrderLineId
set pi.isReserved = 1
limit floor(pol.quantity - pol.availableQuantity);

what would be the better alternative?

  • Can you elaborate with an example what you are trying to achieve, you have to rewrite teh query so that you get a WHERE withouot using the LIMIT
    – nbk
    Jun 22, 2020 at 13:17

1 Answer 1


Write a Stored Procedure that 'constructs' the query, specifically by putting a computed value after LIMIT.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.