我正在创建一个简单的过程来从表中删除一行tbGame
,但是当我尝试调用 proc 它返回error 1093
我试图通过使用普通命令()删除该行来弄清楚发生了什么,DELETE FROM <table>
但它没有用。经过一番研究,我发现这个错误通常发生SELECT
在子查询中有a时,但程序没有,我也尝试关闭derived_merge
但它也不起作用,最后我创建了另一个数据库并尝试了相同的程序并且它有效,所以我认为问题不在我的程序中。
---turning off derived_merge
SET @@optimizer_switch='derived_merge=OFF';
-- that´s the procedure
DELIMITER //
CREATE PROCEDURE sp_DeleteGame (in _idGame int)
begin
delete from tbGame where idGame = _idGame;
end //
DELIMITER ;
-- that´s the normal delete command that I used
DELETE FROM tbGame WHERE idGame = 1;
在这两种情况下,Mysql 都会返回:
'Error Code: 1093. You can't specify target table 'tbGame' for update in FROM clause'