我正在尝试使以下事务工作,但在 SELECT 附近出现 mysql 错误。我仔细检查了所有列名是否正确。
错误信息
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 'INSERT INTO articles (catid,content,title,keywords,isactive) (SELEC' at line 2
SQL
START TRANSACTION;
INSERT INTO articles (catid,content,title,keywords,isactive)
(SELECT 1, pendingarticles.content, pendingarticles.title,
pendingarticles.keywords, 1
FROM pendingarticles
WHERE pendingarticles.id=1);
DELETE FROM pendingarticles WHERE id=1;
COMMIT;
更新
代码本身有效。 INSERT INTO - SELECT 部分和 DELETE 部分。交易出了点问题。也许 ;
?或者我的数据库服务器不能做交易?
最佳答案
MyISAM 引擎不支持事务。 MyIsam engine transaction support
要支持交易,您必须更改引擎 f.e.到 InnoDB。 Setting the Storage Engine
关于mysql - 嵌套的 MySQL 选择错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17725714/