MySQL Workbench Error 1175 Even With a “Where” Statement

匆匆过客 提交于 2019-12-04 06:57:29

问题


I am running MySQL Workbench 6.3.8 b1228 CE (64-bit) in "safe update mode". I am trying to run a query with a "WHERE" statement, but it still returns "Error 1175"

Here is my query statement:

DELETE FROM `my_db`.`table_name` WHERE `email` = 'john@smith.com';

(Obviously "my_db" and "table_name" are placeholders.)

Why would Workbench throw Error 1175 for this query when I have the most basic of "WHERE" statements included?


回答1:


In Sql by default safe options is enabled which restricts the user from deleting or updating the data in table using inappropriate key.To turn of the safe update go to

edit->preferences->sql editor and uncheck the safe update check box at the bottom of the preference window or even you can delete or update referencing the primary key.

For Example: Let us consider we have table called user_details with four fields(name, number, email ,address) where name is the primary key. So your delete statement would look like this

Delete from user_details where name="xxx";

Note: Reconnect to the database after safe update is turned off. Even you can restart the server but reconnect itself works fine.

Hope this solves your issue.




回答2:


maybe is a very simple error. Try delete the row from the user interface. see the attached images.




回答3:


As Arnolio mentions in a comment,

The important part of the error is : "...without a WHERE that uses a KEY column". So i have to ask is the email column a key column?

I wasn't focused on the KEY portion, and my email column wasn't a KEY, which caused the error. Thanks, Arnolio!




回答4:


Consider:

update
    civicrm_address
set
    geo_code_1 = 99999
and
    id is not null

This throws the same error but,

update
    civicrm_address
set
    geo_code_1 = 99999
and
    id <> 0

is successful

Why doesn't the first one work?

(I wanted to post this as a comment but it doesn't allow the formatting)



来源:https://stackoverflow.com/questions/41063705/mysql-workbench-error-1175-even-with-a-where-statement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!