2012-03-26 9 views
0

Ich werde nicht SQL-Tabellen erstellen, aber ich erhalte Fehler.SQL-Syntaxfehler beim Erstellen neuer Tabelle in MySQL

 
#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 , 
) 
+0

Sieht aus wie Sie ein Streu Komma am Ende von 'articles_ratings' haben und vergessen auch die'; 'das erste zu beenden' TABLE' Anweisung CREATE, weshalb MySQL verweist auf einen Syntaxfehler zu Beginn der zweite 'CREATE TABLE'. –

+0

@ kazik1616 Ah ja, das schwer fassbare Archäologie-Abzeichen – Strawberry

Antwort

1

Fügen Sie den Primärschlüssel Aussage Ihre Artikel Ratings oder das letzte Komma entfernen.

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

Vielen Dank. –

Verwandte Themen