将MySQL数据库从 5.1.30 迁移到 5.7.16 之后,一些存储过程一直给我这样的错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'A from Tab A
where A.`Type` = _Type
and A.`ID` '.
有问题的代码片段如下所示:
delete Tab A from Tab A
where A.`Type` = _Type
and A.`ID` = _ID;
根据我对DELETE syntax的MySQL参考手册条目的理解,这应该是一个有效的代码,但它仍然给我错误。
我通过将代码更改为:
来解决问题delete from Tab
where `Type` = _Type
and `ID` = _ID;
但为什么它首先失败了?
我还尝试了根据手册允许的那两种变体,但未能执行:
delete from Tab A
where A.`Type` = _Type
and A.`ID` = _ID;
delete Tab as A from Tab as A
where A.`Type` = _Type
and A.`ID` = _ID;