MYSQL语法错误-为什么会发生这种情况?

MYSQL语法错误-为什么会发生这种情况?,mysql,sql,syntax,Mysql,Sql,Syntax,我在php脚本中使用mysql已经6年多了,但我从未遇到过这样的错误 执行此SQL命令时: SELECT `discount_items`.* FROM `discount_items` WHERE (position=1) AND (active=1) AND (end<=1344007212) AND (show=1) LIMIT 1 表格结构为: CREATE TABLE IF NOT EXISTS `discount_items` ( `id` int(11) NOT NUL

我在php脚本中使用mysql已经6年多了,但我从未遇到过这样的错误

执行此SQL命令时:

SELECT `discount_items`.* FROM `discount_items` WHERE (position=1) AND (active=1) AND (end<=1344007212) AND (show=1) LIMIT 1
表格结构为:

CREATE TABLE IF NOT EXISTS `discount_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` text CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
  `image` text CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
  `discount` float NOT NULL,
  `price1` float NOT NULL,
  `price2` float NOT NULL,
  `bought` int(11) NOT NULL,
  `target` int(11) NOT NULL,
  `desc` text CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
  `link` text CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
  `active` tinyint(1) NOT NULL,
  `start` int(11) NOT NULL,
  `end` int(11) NOT NULL,
  `position` int(11) NOT NULL DEFAULT '1',
  `show` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
我不明白有什么不对。显然是“show”字段导致了问题,但我已经尝试了所有方法。。(show field肯定有问题,因为:

SELECT `discount_items`.* FROM `discount_items` WHERE (show=1) AND (active=1) AND (end<=1344007212) AND (position=1) LIMIT 1
因此,问题会随着表演场地而转移

如果这是一个常见的问题,我很抱歉,但我在谷歌上搜索了一下,什么也没找到。这个错误太全面了,不能向我解释任何事情


感谢您的帮助和提示!

show
是保留字。请更改它或将其置于勾号中

 SELECT `discount_items`.* FROM `discount_items` WHERE (position=1) AND (active=1) AND (end<=1344007212) AND (`show`=1) LIMIT 1

从“折扣项目”中选择“折扣项目”。(位置=1)和(活动=1)和(结束
show
是MySQL保留字。如果要使用它引用字段名,必须在其周围使用倒勾,如下所示:

SELECT `discount_items`.*
FROM `discount_items`
WHERE
    (position=1)
    AND (active=1)
    AND (end<=1344007212)
    AND (`show`=1) /* backticks added here */
LIMIT 1
选择“折扣项目”*
来自“折扣”项目`
哪里
(位置=1)
和(活动=1)

(end
show
是一个MySQL保留字。将其用反勾括起来以使其工作。

谢谢。我想它会是这样的--:)我猜,早起的鸟儿会有虫吃。我只是在键入这个问题的答案,同时发布了两个答案…对它们都投了赞成票…:)我想end也是一个保留字
 SELECT `discount_items`.* FROM `discount_items` WHERE (position=1) AND (active=1) AND (end<=1344007212) AND (`show`=1) LIMIT 1
SELECT `discount_items`.*
FROM `discount_items`
WHERE
    (position=1)
    AND (active=1)
    AND (end<=1344007212)
    AND (`show`=1) /* backticks added here */
LIMIT 1