#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 ')'

寵の児 提交于 2019-12-06 16:46:20

问题


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

Weirdly line 7 is the 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

回答1:


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
);



回答2:


You are getting this error bcoz of an addition 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
);



回答3:


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 ;


来源:https://stackoverflow.com/questions/29446697/1064-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!