MySQL + SQL · Lesson 52
UPDATE and DELETE Commands
UPDATE — Change Data
UPDATE students SET marks = 95 WHERE roll_no = 1;Changes marks to 95 for roll_no 1 only.
DELETE — Remove Rows
DELETE FROM students WHERE roll_no = 5;Deletes the row(s) matching the condition.
The Most Important Rule
ALWAYS use
WHERE with UPDATE/DELETE. DELETE FROM students; with no WHERE deletes EVERY row!Summary
- UPDATE changes existing rows; DELETE removes rows.
- Always add WHERE, or the whole table is affected.