[英]Inserting multiple rows in mysql php
I'm trying to insert multiple rows but I continue getting an sqlerror and cannot for the life of me figure out why. 我正在尝试插入多行,但是我继续收到sqlerror,并且终生无法弄清原因。
echo '"'.$thequery.'"';
$sql = mysql_query($thequery) or die(mysql_error());
return "SUCCESS";
$thequery gets printed out as: "INSERT INTO thistable (rank, change, reqID, vanID) VALUES (1,'PICKUP',28,1),(2,'PICKUP',29,1),(3,'DROPOFF',28,1),(4,'DROPOFF',29,1)" $ thequery的打印输出为:“ INSERT INTO this table(rank,change,reqID,vanID)VALUES(1,'PICKUP',28,1),(2,'PICKUP',29,1),(3,'DROPOFF ',28,1),(4,'DROPOFF',29,1)“
and the error: You have an error in your SQL syntax; 错误:SQL语法错误; check the manual that corresponds to your MySQL server version for the right syntax to use near 'change, reqID, vanID) VALUES (1,'PICKUP',28,1),(2,'PICKUP',29,1),(3,'DROPOFF',28' at line 1 检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在'change,reqID,vanID'附近使用VALUES(1,'PICKUP',28,1),(2,'PICKUP',29,1),( 3,第1行的'DROPOFF',28'
Thanks in advanced. 提前致谢。
CHANGE
is a reserved word in MySQL . CHANGE
是MySQL中的保留字 。 Rename the column or enclose the identifier in backticks. 重命名该列或将标识符括在反引号中。
Besides, you seem to have a typo in the VALUES
part: in (1,'PICKUP,'28,1),(2,'PICKUP,'29,1),
, the ,'
should be ',
. 此外,您似乎在VALUES
部分中有错别字:在(1,'PICKUP,'28,1),(2,'PICKUP,'29,1),
,中,'
应该为',
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.