MySQL error code: 1175 during UPDATE in MySQL Workbench

前端 未结 20 1335
隐瞒了意图╮
隐瞒了意图╮ 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: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..

提交回复
热议问题