πŸ—‘οΈ DELETE – How to Remove Data in SQL

πŸ”§ Quick Syntax:

DELETE FROM table_name
WHERE some_condition;

Basically:
β€œHey SQL, go to this table, and delete the rows that match this condition.”

⚠️ Warning First

NEVER run DELETE without WHERE
Unless you really want to delete everything 😬

DELETE FROM friends;  -- deletes ALL rows!

🧾 Current friends table:

id name age phone
1Olivia265550001234
2Mason245556712345
3Zoe305559083344
4Ethan215554421199
5Harper255552223344

βœ… Example 1: Delete Ethan from the table

DELETE FROM friends
WHERE name = 'Ethan';

πŸ’‘ Output:

Query OK, 1 row affected

Table Now:

id name age phone
1Olivia265550001234
2Mason245556712345
3Zoe305559083344
5Harper255552223344

βœ… Example 2: Delete everyone older than 28

DELETE FROM friends
WHERE age > 28;

πŸ’‘ Output:

Query OK, 1 row affected

Table Now:

id name age phone
1Olivia265550001234
2Mason245556712345
5Harper255552223344

πŸ§ƒ Recap

  • DELETE FROM table WHERE condition removes specific rows
  • NEVER forget the WHERE unless you’re okay deleting everything
  • It’s permanent β€” no undo unless you’ve got backups

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top