0 votes
1 view
in SQL by (180 points)
edited by

I am trying to update the column visited to give it the value 1. I'm using MySQL workbench, and I'm writing the statement in the SQL editor from inside the workbench.When I'm writing the following command:

UPDATE tablename SET columnname=1;

It gives me the below error:

You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option ....

I followed the instructions, and I have also unchecked the safe update option from the Edit menu then Preferences then SQL Editor. The same error still appears & I'm not able to update this value. Please, tell me what's wrong?

1 Answer

0 votes
by (12.7k points)
edited by

It looks like the MySQL session has the safe-updates option set. This means that you cannot update or delete the records without specifying a key (eg. primary key) in the where clause.

Try:

SET SQL_SAFE_UPDATES = 0;

Or you can do modify your query to follow the rule (use primary key in where clause).

If you want to learn more about SQL, Check out this SQL training online by Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...