MySQL error code: 1175 during UPDATE in MySQL Workbench

前端 未结 20 1002
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 09:58

I\'m trying to update the column visited to give it the value 1. I use MySQL workbench, and I\'m writing the statement in the SQL editor from inside the workben

相关标签:
20条回答
  • 2020-11-22 10:32

    I too got the same issue but when I off 'safe updates' in Edit -> Preferences -> SQL Editor -> Safe Updates, still I use to face the error as "Error code 1175 disable safe mode"

    My solution for this error is just given the primary key to the table if not given and update the column using those primary key value.

    Eg: UPDATE [table name] SET Empty_Column = 'Value' WHERE [primary key column name] = value;

    0 讨论(0)
  • 2020-11-22 10:34
    SET SQL_SAFE_UPDATES=0;
    UPDATE tablename SET columnname=1;
    SET SQL_SAFE_UPDATES=1;
    
    0 讨论(0)
  • 2020-11-22 10:36

    True, this is pointless for the most examples. But finally, I came to the following statement and it works fine:

    update tablename  set column1 = '' where tablename .id = (select id from tablename2 where tablename2.column2 = 'xyz');
    
    0 讨论(0)
  • 2020-11-22 10:39

    just type SET SQL_SAFE_UPDATES = 0; before the delete or update and set to 1 again SET SQL_SAFE_UPDATES = 1

    0 讨论(0)
  • 2020-11-22 10:42
    SET SQL_SAFE_UPDATES=0;
    

    OR

    Go to Edit --> Preferences

    Click SQL Queries tab and uncheck Safe Updates check box

    Query --> Reconnect to Server

    Now execute your sql query

    0 讨论(0)
  • 2020-11-22 10:43

    Since the question was answered and had nothing to do with safe updates, this might be the wrong place; I'll post just to add information.

    I tried to be a good citizen and modified the query to use a temp table of ids that would get updated:

    create temporary table ids ( id int )
        select id from prime_table where condition = true;
    update prime_table set field1 = '' where id in (select id from ids);
    

    Failure. Modified the update to:

    update prime_table set field1 = '' where id <> 0 and id in (select id from ids);
    

    That worked. Well golly -- if I am always adding where key <> 0 to get around the safe update check, or even set SQL_SAFE_UPDATE=0, then I've lost the 'check' on my query. I might as well just turn off the option permanently. I suppose it makes deleting and updating a two step process instead of one.. but if you type fast enough and stop thinking about the key being special but rather as just a nuisance..

    0 讨论(0)
提交回复
热议问题