gpt4 book ai didi

MySQL 错误 1064 - 在一个查询中执行两个插入语句;这有什么问题吗?

转载 作者:行者123 更新时间:2023-11-29 11:00:29 25 4
gpt4 key购买 nike

我的查询有什么问题?我尝试使用一个查询插入执行两个插入语句,但出现此错误:

Error 1064: 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 todo (title, slug, description, user_id) VALUES (?, ?, ?, ?); ' at line 2

我已阅读该错误,但我没有发现该插入语句有任何问题,我在这里缺少什么?

BEGIN;
INSERT INTO todo (title, slug, description, user_id)
VALUES (?, ?, ?, ?);

SET @last_insert_id = LAST_INSERT_ID();

INSERT INTO todo_category (todo_id, category_id)
VALUES (@last_insert_id, ?),
(@last_insert_id, ?),
(@last_insert_id, ?);
COMMIT;

在执行查询之前,问号将被消耗为值。

最佳答案

您必须问自己:“我的值(value)观是什么”?

您似乎缺少准备声明。 Check this catch 它。

关于MySQL 错误 1064 - 在一个查询中执行两个插入语句;这有什么问题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42378358/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com