In the table, rows are generated initially (a list of PIN codes) and then only two fields are updated: status status (from 0 to 1 and back) and order number field ord_id PIN codes with certain IDs (a series in succession) in one order I do this:
UPDATE pin_codes SET status=1, ord_id=223344 WHERE status=0 AND (id BETWEEN 300 AND 345) If all the requested PIN codes have already been sold (status = 1), then the update will not happen, everything is ok.
If all the requested PIN codes are free, then everything is OK too - an update will occur as expected.
Question : how to disable the update, if a part of the requested interval of PIN codes has already been sold, that is, in fact, only part of the lines will be updated.
The point is that the sale is by series, but different customers choose different series, for someone the series from 300 to 345 is suitable, for someone from 300 to 400, for someone from 320 to 350 and so on and always completeness series.
Crazy thought to first make a select and then immediately threw it out on the results of the update
That is, if simplified, then allow to make an update only when all the conditions are met