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.
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

WhatsApp