我在我的PHP腳本中使用MySQL超過6年,但我從未遇到像這樣的錯誤。MYSQL語法錯誤 - 爲什麼會發生這種情況?
當我執行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
所以,問題與秀場移動。
我很抱歉,如果這是常見的問題,但我用Google搜索並沒有發現這個錯誤太全局和沒有解釋任何東西給我。
感謝任何他lp和提示!
謝謝。我以爲它會是這樣的--_- :) – user1574556 2012-08-03 15:46:39
我想,早起的鳥兒會發現蠕蟲。我只是打出了這個問題的答案,同時發佈了2個答案...... Upvoted他們兩個...... :) – verisimilitude 2012-08-03 15:50:00
我認爲**結束**也是一個保留字 – hmmftg 2012-08-03 15:50:21