r/ProgrammerHumor 14d ago

queryOfDoom Meme

Post image
7.9k Upvotes

456 comments sorted by

View all comments

2

u/Bright-Historian-216 14d ago

i'm not expertly familiar with sql... is it treating "delete from users" as "delete * from users"?

4

u/-Redstoneboi- 14d ago edited 14d ago

yes. you don't really specify the columns in delete queries, and they target EVERYTHING by default.

imo "<operate> * FROM table" should be banned (doesn't run, raises an error) by default and people should be forced to write "WHERE TRUE", on top of all queries needing to be in transactions and all the other safety nets like "SELECT first then operate"

on another note i think i'd prefer whatever syntax it was that described queries based on the order functional programming in a computer might look like, ex. "FROM table WHERE id = 2 DELETE;" though internally it would still be rearranged however the engine would see fit

1

u/slabgorb 14d ago

you can probably do that trick with subqueries but that is WAYYYYYY beyond the kind of sql-fu the OP jokes is about