0

i'm practicing on MySQL and i have a question about the "where" clause , why in MySQL the condition that comes after "where" should be in the primary key ? if i put any condition other than the primary key it will be an error !!

for example i have a table called "students" with 4 columns , first one is "stuid" and its the primary key and there are "stuname" , "classroom" , "stuage" and these are the rest of the columns why i can't say for example

update students set stuname = 'sarah' where classroom = 46;

and this is the error :

" Error Code: 1175. 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 in Preferences -> SQL Editor and reconnect."

i tried to do what the messsage says but i didnt understand the part about "reconnect"

hence : i'm using MySQL on mac

khalid althwab
  • 11
  • 1
  • 1
  • 3
  • Possible duplicate of [MySQL error code: 1175 during UPDATE in MySQL Workbench](https://stackoverflow.com/questions/11448068/mysql-error-code-1175-during-update-in-mysql-workbench) – Sam M Feb 23 '18 at 05:10

1 Answers1

1

we can use any key's with update. the issue may be with the IDE you are using.Kindly specify the IDE and MySQL version you are using. or google about Turing off the safe mode in your IDE/MySQL.

What is Safe Mode?

it is used to prevent the unnecessary/accidentally updating a bunch of rows in a table.(where clause with non-unique keys)

to turn of the safe mode try

SET SQL_SAFE_UPDATES = 0;

its safer to turning on the safe mode after use.

SET SQL_SAFE_UPDATES = 1;