简体   繁体   English

无法找出此MySQL语法错误

[英]Can't figure out this MySQL syntax error

here is 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 'order ASC LIMIT 100' at line 1. 查看与您的MySQL服务器版本相对应的手册以获取正确的语法,以在第1行的“ order ASC LIMIT 100”附近使用。

here is the query passed to PDO for a prepared execute 这是传递给PDO以准备执行的查询

SELECT * FROM web_menu_items WHERE menuId = ? ORDER BY order ASC LIMIT 100

here are the variables passed to the prepared execute 这是传递给准备好的执行的变量

array(0 => "1")

here is the table structure 这是表结构

CREATE TABLE IF NOT EXISTS `web_menu_items` (
  `id` int(11) NOT NULL auto_increment,
  `menuId` int(11) NOT NULL,
  `order` int(11) NOT NULL,
  `requiredAccess` int(11) NOT NULL,
  `hideIfNotAccess` int(11) NOT NULL,
  `label` varchar(128) NOT NULL,
  `link` varchar(128) NOT NULL,
  `tagId` varchar(32) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `menuId` (`menuId`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;

what am I not seeing here? 我在这里没看到什么? why is this a syntax error? 为什么这是语法错误?

order is a reserved word in mySQL. order是mySQL中的保留字。

Put backticks around it: 加上反引号:

ORDER BY `order` ASC LIMIT 100

or consider renaming the field. 或考虑重命名该字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM