我在我的 php 脚本中使用 mysql 超过 6 年,但我从未遇到过这样的错误。
当我执行这个 SQL 命令时:
SELECT `discount_items`.* FROM `discount_items` WHERE (position=1) AND (active=1) AND (end<=1344007212) AND (show=1) LIMIT 1
它向我抛出了这个错误
#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 'show=1) LIMIT 1' at line 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;
我不明白有什么问题。显然,“显示”字段会导致问题,但我已经尝试了一切......(显示字段一定有问题,因为:
SELECT `discount_items`.* FROM `discount_items` WHERE (show=1) AND (active=1) AND (end<=1344007212) AND (position=1) LIMIT 1
投掷
#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 'show=1) AND (active=1) AND (end<=1344007212) AND (position=1) LIMIT 1' at line 1
所以问题转移到了显示领域。
如果这是常见问题,我很抱歉,但我用谷歌搜索却一无所获。这个错误太全球化了,对我没有任何解释。
感谢您的帮助和提示!