News for hackers. Stuff that matters.
Re:How I destroyed the company's DB (a stupid SQL mistake) by crazygringo on Monday January 01, 2024 @01:29PM (#38834056)
Because of this, it's also customary to use a LIMIT just in case.

For something like this, LIMIT 3 if you assume the query is correct (e.g. in production), or LIMIT 4 if you're running it manually -- so that if it reports 4 rows changed instead of 3, you know you messed up somewhere, but at least you only have up to 4 rows to fix by hand, rather than an entire table.

Re:How I destroyed the company's DB (a stupid SQL mistake) by AntonZ234 on Monday January 01, 2024 @01:35PM (#38834130)
I’m used to using limits purely in select queries, honestly I didnt event know its applicable for update queries.

Still, it would probably have been after the where, and ignored too.

not using transactions is probably my biggest mistake here.

Re:How I destroyed the company's DB (a stupid SQL mistake) by cortesoft on Monday January 01, 2024 @01:38PM (#38834167)
Would not have helped, since the limit would have applied to the second statement in this case.

The issue wasn’t the statement, it was the tool thinking blank line == end ststement.

Re:How I destroyed the company's DB (a stupid SQL mistake) by mlyle on Monday January 01, 2024 @01:35PM (#38834119)
Of course, the LIMIT is no good here because the correctly-written statement is truncated.