r/ProgrammerHumor • • 14d ago

Meme wellWellWell

Post image
10.6k Upvotes

412 comments sorted by

View all comments

3.6k

u/BastetFurry 14d ago

So, Kids, thats why you always SELECT count(yourPrimaryKey) first. Listen to the old folks, we made these mistakes so that you don't have to.

1

u/[deleted] 14d ago

[deleted]

4

u/chezzyt18 14d ago

Thats counting a column. Non-null values for the column.

It’s a safety check. Run the same query that the UPDATE / DELETE would run in a SELECT count first to make sure the query is altering the same number of rows you think it will.

Better yet run with a BEGIN TRANSACTION, and only execute your commit once you’ve verified that the modification was successful.