我在 MariaDB 中执行 SQL 查询时遇到了一个小问题.所有 PHP 变量都不为空,我想同时执行两个查询.在 MySQL 中它可以工作,但在 MariaDB 服务器中我不能,因为我得到一个错误我有一个查询:
I have faced a slight problem with executing SQL query in MariaDB. All PHP variables are not empty and I would like to execute two queries at the same time. In MySQL it is working but in MariaDB server I cannot as I get an error I have a query:
UPDATE users SET name = $receivedName, email = $receivedEmail WHERE id = $id1; UPDATE posts SET id = $userid WHERE id = $receivedID
我得到的错误:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE posts SET id = 50 WHERE id = 56 /* /takechange.php */' at line 1
我知道执行分配给单个变量的两个查询并不是一个好主意,但目前我几乎无法更改任何代码.我想这不是如何在 MariaDB 中加入多个查询.你能告诉我如何编辑这个查询吗?
I know it is not a shiny idea to execute two queries which are assigned to single variable, but at the moment I can barely change any code. I guess this is not how to join multiple queries in MariaDB. Can you tell me how to edit this query?
提前致谢.
您需要使用 mysqli Multi Query 或执行您的语句单独.
You need to use mysqli Multi Query or execute your statements separately.
如您所知,您有多个正在传递的语句.
You have multiple statements being passed as you know.
多查询
执行一个或多个由 a 连接的查询分号.
Executes one or multiple queries which are concatenated by a semicolon.
这篇关于无法使用 PHP 执行多个 MariaDB 查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!