22
rubyDom
8y

That moment when you realise you didn't put a WHERE on your update SQL. And now every row in that table is wrong. Fml

Comments
  • 5
    Every row can't be wrong; the ones your missing where clause should have found are now correct ;)
  • 0
    that's why I triple check my triple checks when I work with queries other than SELECT
  • 1
    From now on I'm writing the where but first!
    Or just getting a web interface to edit this stuff.
  • 3
    The reason why I always do a select first to check if the amount of rows is as expected
  • 2
    UPDATE: restored backup to new db, updated all the (now) correct data. Job done. No harm done.
  • 2
    I always write the where clause before the set clause, at least just the keyword "where" so the query doesn't compile before the where is completed
  • 1
    I do a select-query first, to ensure that The correct row is changed.
  • 5
    Yes, this is the mistake you only do once. Lesson learned. You are not the first.
  • 1
    I always execute a select to check if the rows I'm selecting are the ones I want to update.

    I always keep instructions other than SELECT commented or even delete them completely to ensure a mistaken execution of the whole script won't cause any harm.
Add Comment