How to Update a column in MySQL

1 Answer(s)
To update rows that match a certain condition.

–For Example, This will update only one row that matches product_id=1

UPDATE products SET stocks=100, available=true
WHERE product_id=1;

--For Example, This will update multiple rows that match Category='Electronics'
UPDATE products SET stocks=50, available=true
WHERE category='Electronics';

To update all rows in a MySQL table, just use the UPDATE statement without a WHERE clause:

UPDATE products SET stocks=100;
Answered on September 2, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.