SQL 请求 CREATE TEMPORARY TABLES(在终端工作但不通过 php)
SQL request CREATE TEMPORARY TABLES (working in terminal but not via php)
我使用 Javascript ajax 从数据库调用 PHP
到 select 信息。
当我将粘贴 CREATE TEMPORARY TABLE
SQL 语句直接复制到终端 mysql
时,它工作正常
但是 PHP returns 我的请求出错了...
错误:
success:"false"
title:"ERROR"
msg:"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 'CREATE TEMPORARY TABLE thismonth AS (SELECT ' at line 1"
好吧终于自己找到了答案...
对于那些有同样问题的人,只需将每个查询分开,如下所示:
mysqli_query("DROP TABLE IF EXISTS thismonth;", $rMysqlLink);
mysqli_query("CREATE TEMPORARY TABLE thismonth AS (SELECT product_id from product);", $rMysqlLink);
mysqli_query("SELECT product_id from thismonth;", $rMysqlLink);
它有效,我不知道为什么 php 不能与所有合一,但没关系:)
我使用 Javascript ajax 从数据库调用 PHP
到 select 信息。
当我将粘贴 CREATE TEMPORARY TABLE
SQL 语句直接复制到终端 mysql
时,它工作正常
但是 PHP returns 我的请求出错了...
错误:
success:"false"
title:"ERROR"
msg:"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 'CREATE TEMPORARY TABLE thismonth AS (SELECT ' at line 1"
好吧终于自己找到了答案... 对于那些有同样问题的人,只需将每个查询分开,如下所示:
mysqli_query("DROP TABLE IF EXISTS thismonth;", $rMysqlLink);
mysqli_query("CREATE TEMPORARY TABLE thismonth AS (SELECT product_id from product);", $rMysqlLink);
mysqli_query("SELECT product_id from thismonth;", $rMysqlLink);
它有效,我不知道为什么 php 不能与所有合一,但没关系:)