#1064 - 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在“)”附近使用的正确语法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29446697/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
#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 ')'
提问by user3526002
This is the code. However I kept getting this error
这是代码。但是我一直收到这个错误
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 ')' at line 7
1064 - 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在第 7 行的“)”附近使用的正确语法
Weirdly line 7 is the CREATE TABLE academicnews( line. Which does not contain ')'
.
奇怪的是第 7 行是CREATE TABLE academicnews( line. Which does not contain ')'
.
CREATE TABLE academicnews(
anewsID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(50) NOT NULL,
anewsContent TEXT NOT NULL,
imagePath VARCHAR(200) NOT NULL,
timeNews DATE NOT NULL,
); #Line 7
回答by John Conde
Get rid of the last comma. It is unnecessary and invalid.
去掉最后一个逗号。这是不必要的和无效的。
CREATE TABLE academicnews(
anewsID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(50) NOT NULL,
anewsContent TEXT NOT NULL,
imagePath VARCHAR(200) NOT NULL,
timeNews DATE NOT NULL, <-- HERE
);
It should be
它应该是
CREATE TABLE academicnews(
anewsID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(50) NOT NULL,
anewsContent TEXT NOT NULL,
imagePath VARCHAR(200) NOT NULL,
timeNews DATE NOT NULL
);
回答by Beginner
You are getting this error bcoz of an addition comma
.
您收到此错误 bcoz 的添加comma
。
CREATE TABLE academicnews(
anewsID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(50) NOT NULL,
anewsContent TEXT NOT NULL,
imagePath VARCHAR(200) NOT NULL,
timeNews DATE NOT NULL, <--- This is the error
);
回答by user8684215
CREATE TABLE IF NOT EXISTS `testinfo` (
`id` int(8) NOT NULL AUTO_INCREMENT,
`sl_no` int(10) NOT NULL,
`p1` int(3) DEFAULT NULL,
`p2` int(3) DEFAULT NULL,
`p3` int(3)DEFAULT select [p1]+[p2],
`mid` int(8) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `mid` (`mid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;