gpt4 book ai didi

mysql - MySQL新建表时SQL语法错误

转载 作者:行者123 更新时间:2023-11-29 14:31:48 25 4
gpt4 key购买 nike

我不会创建 sql 表,但收到错误。

#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 'CREATE TABLE `articles_ratings` ( `ID` INT(11) NOT NULL AUTO_INCREMENT, `a' at line 10
CREATE TABLE `articles` (
`ID` int( 11 ) NOT NULL AUTO_INCREMENT ,
`a_title` varchar( 255 ) ,
`a_subtitle` tinytext,
`a_content` text,
PRIMARY KEY ( `ID` )
)

CREATE TABLE `articles_ratings` (
`ID` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`article_id` int( 11 ) NOT NULL ,
`rating_value` tinyint( 2 ) NOT NULL ,
`rater_ip` varchar( 20 ) NOT NULL ,
)

最佳答案

将主键添加到您的文章评级声明中或删除最后一个逗号。

CREATE TABLE articles ( 
ID int( 11 ) NOT NULL AUTO_INCREMENT ,
a_title varchar( 255 ) ,
a_subtitle tinytext,
a_content text,
PRIMARY KEY ( ID )
);
CREATE TABLE articles_ratings (
ID INT( 11 ) NOT NULL AUTO_INCREMENT ,
article_id int( 11 ) NOT NULL ,
rating_value tinyint( 2 ) NOT NULL ,
rater_ip varchar( 20 ) NOT NULL ,
PRIMARY KEY ( ID )
);

关于mysql - MySQL新建表时SQL语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9872881/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com