MySQL Forums
Forum List  »  Newbie

Error 1175 - I an trying to update a column in every record
Posted by: Chad Ramos
Date: February 20, 2011 10:57AM

Hi,

I am trying to run this query, whic basically updates a column of every row in the table...

UPDATE CUSTOMER
SET CUST_AGE = YEAR(CURDATE()) - YEAR(CUST_DOB);

And am getting this error...

Error Code: 1175. To disable safe mode, toggle the option in Preferences -> SQL Editor -> Query Editor and reconnect.
You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column

Now if my research is correct this has to do with the fact that I am not specifiying a key for each row. i.e. using a WHERE statement.

Looking around online the only solution I can seem to find is to turn safe off before the query and on after. Like so....

SET SQL_SAFE_UPDATES=0;

UPDATE CUSTOMER
SET CUST_AGE = YEAR(CURDATE()) - YEAR(CUST_DOB);

SET SQL_SAFE_UPDATES=1;

I am wondering is this the only way to update a column of every row in a table, or is there an option where I don't have to turn SQL_SAFE_UPDATES on then off.

Thanks

Chad



Edited 1 time(s). Last edit at 02/20/2011 10:59AM by Chad Ramos.

Options: ReplyQuote


Subject
Written By
Posted
Error 1175 - I an trying to update a column in every record
February 20, 2011 10:57AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.