user3502112
user3502112

Reputation: 21

I'm trying to create a database but i keep getting the same error, and according to me and my fellow students the code is fine

This is just an example, from the first 2 tables but I get the same error:

MySQL said: Documentation

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 10

CREATE TABLE Tallas
(
IDTalla int NOT NULL AUTO_INCREMENT,
descripcion varchar(45) NOT NULL,
PRIMARY KEY (IDTalla),
)

CREATE TABLE Modelo
(
IDModelo int NOT NULL AUTO_INCREMENT,
IDTalla int NOT NULL,
modeloNombre varchar(45) NOT NULL,
precio varchar(45) NOT NULL,
informacion varchar(45) NOT NULL,
PRIMARY KEY (IDModelo),
FOREIGN KEY (IDTalla) REFERENCES Modelo(IDTalla),
)

Upvotes: 2

Views: 77

Answers (3)

JFPicard
JFPicard

Reputation: 5168

Remove the coma at PRIMARY KEY (IDTalla), to make it PRIMARY KEY (IDTalla)

and the same with REFERENCES Modelo(IDTalla),

Upvotes: 7

PaddyMack
PaddyMack

Reputation: 73

Looks like you put an extra comma in your create table statement just after primary key.

CREATE TABLE Tallas ( 
  IDTalla int NOT NULL AUTO_INCREMENT, 
  descripcion varchar(45) NOT NULL, 
  PRIMARY KEY (IDTalla), 
)

This should be:

CREATE TABLE Tallas ( 
  IDTalla int NOT NULL AUTO_INCREMENT, 
  descripcion varchar(45) NOT NULL, 
  PRIMARY KEY (IDTalla) 
)

Same with the second statement.

Upvotes: 0

ShadowMeldFS
ShadowMeldFS

Reputation: 63

Remove the comma -> (IDTalla),) (IDTalla))

Upvotes: 1

Related Questions