Need help… I want to subtract the prod_piece from the customer table into prod_qty product table when every time the user purchase.(prod_piece - prod_qty)
This is my SQL:
UPDATE product o INNER JOIN customer p ON p.prod_name = o.id set o.prod_qty = o.prod_qty - p.piece;
UPDATE product o set o.total_price = o.prod_qty * o.prod_price;
The problem with this SQL is that it can subtract, but it only accepts the previous piece order by the user.