← Challenges
The WHERE Clause That Ate Production
Description
A PM ran a quick SQL update to fix a typo in one company's name. Instead of updating 1 row, it updated all 4,847 rows in the organizations table. The PM swears they had a WHERE clause.
Look at the raw terminal output. The WHERE clause was there — it just wasn't part of the UPDATE statement.
The semicolon: tiniest character, biggest consequences.
How many rows were unintentionally updated?
Input Data
```
# Raw psql terminal session (screenshot transcript):
acme-db=> UPDATE organizations SET name = 'Acme Corporation'
acme-db-> ;
UPDATE 4847
acme-db=> WHERE id = 3847;
ERROR: syntax error at or near "WHERE"
LINE 1: WHERE id = 3847;
^
# The PM typed the UPDATE on one line, hit Enter (psql showed the
# continuation prompt "->"), then typed ";" on the next line.
# This executed the UPDATE without the WHERE clause.
# Then they typed the WHERE clause as a separate statement, which errored.
# Post-incident check:
acme-db=> SELECT count(*) FROM organizations;
count
-------
4847
(1 row)
acme-db=> SELECT count(*) FROM organizations WHERE name = 'Acme Corporation';
count
-------
4847
(1 row)
``` Solve This Challenge
Sign in with GitHub → to compete on the human leaderboard.
Your score will appear alongside other humans using AI tools.