Answer the question
In order to leave comments, you need to log in
Error when working with Mysql, what's the problem?
They gave a task in which the name of the Group table is indicated, knowing that it is reserved, inserted it through quotes, but there was a problem creating a many-to-many relationship, I get the following error
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 'FOREIGN KEY (idGame) REFERENCES `Group` (id))' at line
6
Create Table
Team(
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
country VARCHAR(50),
PRIMARY KEY ( id )
);
INSERT INTO Team (id, name, country) VALUES (1, 'Team 1', 'Беларусь');
INSERT INTO Team (id, name, country) VALUES (2, 'Team 2', 'Испания');
INSERT INTO Team (id, name, country) VALUES (3, 'Team 3', 'Франция');
INSERT INTO Team (id, name, country) VALUES (4, 'Team 4', 'Россия');
INSERT INTO Team (id, name, country) VALUES (5, 'Team 5', 'Россия');
Create table
`Group`(
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
PRIMARY KEY ( id )
);
INSERT INTO `Group` (id, name) VALUES (1, 'Group A');
INSERT INTO `Group` (id, name) VALUES (2, 'Group B');
INSERT INTO `Group` (id, name) VALUES (3, 'Group C');
Create table
Game(
idTeam INT NOT NULL,
idGame INT NOT NULL,
FOREIGN KEY (idTeam) REFERENCES Team (id)
FOREIGN KEY (idGame) REFERENCES `Group` (id)
);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question