0

I'm trying to add a numeric value to a column whose "AuthDate" is "06/05/20" and "Time" is "1P -2P".

I ran the following query:

update main
set calls = 2072
where authdate = '06/05/20'
and time = '1P - 2P';

*main = table name calls = column name

but I get error code 1175 You are using safe update mode

Does anyone know why I get the error?

GMB
  • 216,147
  • 25
  • 84
  • 135

1 Answers1

0

Your database or session has option sql_safe_updates enabled. Amongst other things, this forbids update that do not have a where clause, or that have a where clause whose columns are not keys (are not indexed). Even if there is an index, but the optimize chooses not to use it, the query is also aborted.

This is more of an option that prevents mistakes from beginners. If you really know what you are doing, you can disable the option at session level:

set sql_safe_updates = 0;

Side note: I am suspicious about condition authdate = '06/05/20':

  • if autdate is of a date-like datatype, then you should give it a legitimate date string, like: authdate = '2020-06-05' (or '2020-05-06'?)

  • if it's a string then... consider storing it as a date; storing dates as string is bad practice for many reasons, and should be avoided

GMB
  • 216,147
  • 25
  • 84
  • 135
  • It worked! As you mentioned, authdate is currently stored as a string and is needed to be stored as a date. Thank you for your help – Tajima Tsubasa Oct 22 '20 at 02:04