我真的被车轴缠住了。
我正在尝试从表中删除一些记录。
这不起作用...
delete from table where id in (select id from table where ...
...因为我遇到了可怕的...
ERROR 1093 (HY000) at line 1: You can't specify target table for update in FROM clause
...所以我选择了临时表选项...
create temporary table idTemp (idt bigint(20) unsigned); insert into idTemp select id from table where [...]; delete from table where id in (select idt from idTemp); drop table idTemp;
...仅在以 root 身份运行时才有效。如果我以所需的用户身份运行,无论我授予用户多少权限,我都会被拒绝访问。
我尝试添加 CREATE、DROP、INSERT、DELETE、SELECT,但仍然无法访问。
但是当我尝试授予用户 CREATE TEMPORARY TABLES 访问权限时,我得到...
ERROR 1144 (42000): Illegal GRANT/REVOKE command
我在 Linux 上运行 MySQL 版本 5.5.14。
任何帮助将不胜感激!
最佳答案
您还可以将原始查询表达为连接
:
DELETE t
FROM table t
JOIN (SELECT id FROM table WHERE ...) todelete ON t.id = todelete.id
关于mysql根据select语句从同一个表中删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28686964/