Reputation: 529
I am using MySQL 5.6. In my application on a certain window I have the following:
qry2 = 'UPDATE `listprojects` SET `autoassign` = %i WHERE `number` = "%s" ' %( autoassign, autoassign2)
system.db.runUpdateQuery(qry2)
where number is unique in the table, though not indexed. This is throwing an error despite the UPDATE statement only updating a single row.
How can I make it so this query doesn't get caught by SQL_SAFE_UPDATES? Do I have to make the number column an index or something else?
Upvotes: 0
Views: 54
Reputation: 781626
The documentation explains why you can get this error even when you have a WHERE
clause:
With
--safe-updates
, you can modify rows only by specifying the key values that identify them, or aLIMIT
clause, or both
If you don't have an index on the number
column, then you're not specifying a key value.
Add an index on the column and the error should go away.
Upvotes: 1