0
DELETE FROM albums WHERE release_year IS NULL;

I am running this SQL Query to delete rows that have release_year as null, but this throws an error telling me that,

You are using safe update mode and trying to update a table without a where keyword
Sourav Das
  • 75
  • 1
  • 6

1 Answers1

1

It seems like your MySql session has the safe-updates option set. This means it can't update or delete records without specifying a key (ex. primary key) in the where clause. If you don't want to specify the key in the where clause then executes the below code first and then try executing your query.

SET SQL_SAFE_UPDATES = 0;

Ishan Anand
  • 119
  • 1
  • 7
  • Ok so we can't update/delete without primary key. Got it. – Sourav Das Apr 01 '23 at 11:40
  • It seems this works too: `DELETE FROM albums WHERE release_year IS NULL LIMIT 10;` This will delete the first 10 records. Change 10 to a higher number to delete more records. – Luuk Apr 01 '23 at 12:22