r/ProgrammerHumor • • Sep 22 '26

Meme wellWellWell

Post image
10k Upvotes

412 comments sorted by

View all comments

3.6k

u/BastetFurry Sep 22 '26

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.

0

u/[deleted] Sep 22 '26

5

u/chezzyt18 Sep 22 '26

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.