I have the following query:
SET @q = 12;
UPDATE `table`
SET qty = CONCAT(GREATEST(qty - @q, 0), LEFT(@q := @q - LEAST(qty, @q), 0))
ORDER BY id;
(Go vote eggyal up for the great query here: Removing a quantity from multiple rows in a database )
I am running the query (without preparing in this case) through OOP PDO / MySQL.
I want to pass the value of the @q back to PHP or any flag really if @q did not get to 0. I'm not sure how to accomplish this. If anyone is able to point me in the right direction, I'd appreciate it.
Thanks