【问题标题】:You have an error in your SQL syntax; MySql您的 SQL 语法有错误; mysql
【发布时间】:2013-02-01 14:48:02
【问题描述】:

表架构:

CREATE TABLE IF NOT EXISTS `movie` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` text NOT NULL,
  `desc` text NOT NULL,
  `review` text NOT NULL,
  `image_url` text NOT NULL,
  `promo_url` text NOT NULL,
  `created_on` datetime NOT NULL,
  `modified_on` datetime NOT NULL,
  PRIMARY KEY (`id`)
)

插入语句:

INSERT INTO movie (name, desc, review, image_url, promo_url, created_on, modified_on) VALUES ('?p0', '?p1', '?p2', '?p3', '?p4', '?p5', '?p6')

错误:

#1064 - 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 'desc, review, image_url, promo_url, created_on, modified_on) VALUES ('?p0', '?p1' at line 1

我无法找出错误来源,谁能指出它?

【问题讨论】:

    标签: mysql sql error-handling


    【解决方案1】:

    desc 是一个reserved word。将其包装在刻度中或将其更改为“描述”或任何其他非保留名称。

    【讨论】:

      【解决方案2】:

      对我来说,代码有效。也许“desc”有问题(尽管你有反引号)?

      【讨论】:

        【解决方案3】:

        DESC 是 MySQL 中的保留字。

        不过,您仍然可以在表定义中使用它。只需用反引号括起来:

        (name, `desc`, ...
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2012-10-10
          • 1970-01-01
          • 2014-10-25
          • 2019-12-03
          • 2016-02-16
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多