php - sql语法中的奇怪错误

标签 php mysql sql opencart

<分区>

我有几行代码应该在 OpenCart 1.4.9 中生成关于优惠券的报告,但我无法克服这个错误:

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
 'order where coupon_id = 16' at line 1.
$getcouponinfo1 = mysql_query("select * from order where coupon_id = $coupon_id")
      or die(mysql_error());

其余代码可以找到here .

最佳答案

order是SQL中的关键字,需要在表名前加引号。

select * from `order` where ...

关于php - sql语法中的奇怪错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9546542/

相关文章:

php - 如何防止在此查询中被零除?

mysql - 比较mysql中的2列

php - 理解 sys_getloadavg();

php - android room not null 约束在插入时失败

php - mysqli_fetch_assoc()需要参数/调用成员函数bind_param()错误。如何获取并修复实际的mysql错误?

php - 如何根据表中的列值连接表

php - 如何将 Laravel 安装程序 "laravel/installer"更新到最新版本?

php mysql 当父订单的值 = 1 时选择订单详细信息

java - JOOQ 如何在不展平属性的情况下获取连接到 POJO 的结果?

sql - 在 PostgreSQL 中将分钟转换为小时