MySQL error code: 1175 during UPDATE in MySQL Workbench

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

    If you're having this problem in a stored procedure and you aren't able to use the key in the WHERE clause, you can solve this by declaring a variable that will hold the limit of the rows that should be updated and then use it in the update/delete query.

    DELIMITER $
    CREATE PROCEDURE myProcedure()
    BEGIN
        DECLARE the_limit INT;
    
        SELECT COUNT(*) INTO the_limit
        FROM my_table
        WHERE my_column IS NULL;
            
        UPDATE my_table
        SET my_column = true
        WHERE my_column IS NULL
        LIMIT the_limit;
    END$
    

提交回复
热议问题