← SQL tutorial

SQL

UPDATE & DELETE

UPDATE table SET column = value WHERE condition changes existing rows. DELETE FROM table WHERE condition removes rows the same way.

Example: updating one specific row

UPDATE students SET score = 95 WHERE name = 'Chidi';
1 row updated.

The WHERE clause here isn't optional in practice, even though it's technically optional in syntax, leaving it off updates every single row in the table, not just the one you meant. This is one of the most common, most damaging mistakes anyone makes with SQL, and it's worth developing the habit of writing and double-checking your WHERE clause before you even glance at the SET or the rest of the statement. The exact same warning applies to DELETE, with even less room for a second chance.

Example
UPDATE students SET score = 95 WHERE name = 'Chidi';
Output
1 row updated.
Ready to go further?

These free tutorials are a preview, our Backend Development cohort covers it in depth, with a real project and a cohort alongside you. Active

Enroll in Backend Development
Don't miss out

Ready to build something real?

Create a free account to enroll in a track, and get notified the moment a cohort opens.

Create free account