The Kernel Panic Mug (id 10) got 5 more units. A teammate wrote the statement that is in the editor.
- Read the statement. How many rows will it change? Answer before you run it.
- Run it. Read the count in the output, then look at the
stockcolumn in the products tab. - Repair the data: every product except the Kernel Panic Mug goes back to its old stock. The mug keeps its 5 new units.
This time the damage could be repaired, because + 5 can be reversed with - 5. With SET stock = 0, the old values would be gone.
Now make a change the safe way. The shop cuts the price of every Plush product (category_id 1) that costs less than 30.00 by 2.00.
- Preview: show every column of the rows that the change will hit.
- Make the change. Use the same WHERE.
- How many rows did your UPDATE change? It must be the same as the number of rows in your preview.