Create Table IF NOT EXISTS Advisors
(
AdvisorID int primary Key auto_increment Not Null,
FirstName char(50),
LastName char(50),
`EmailAddr` varchar(100)
);
Create Table IF NOT EXISTS Students
(
StudentID int auto_increment not null primary key,
FirstName Char(50),
LastName char(50),
BirthDate date,
Gender Char(6),
StartDate date,
GPA numeric(3,0),
IsActive bit,
Bio text,
AdvisorID int,
foreign key (AdvisorID) references Advisors(AdvisorID)
);
create table IF NOT EXISTS Classes
(
ClassID int primary Key auto_increment not null,
ClassCode varchar(50),
ClassName char(100),
Description varchar(500)
);
create table IF NOT exists Students_Classes
(
StudentClassID int primary key auto_increment not null,
StudentID int,
ClassID int,
StartDate date,
Assignment1 int(100),
Assignment2 int(100),
Assignment3 int(100),
Assignment4 int(100),
ClassGPA numeric(3,0),
foreign key StudentID REFERENCES Students(StudentID),
foreign key ClassID REFERENCES Classes(ClassID)
);
错误代码:1064。您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以获得正确的语法,以便在学生(StudentID),外键ClassID REFERENCES Classes(ClassID)'在第12行
我试图删除引用,看看它在哪里得到的只是一个不同的错误
错误代码:1064。您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册,以获得正确的语法,以便在'附近使用。外键ClassID)'在第12行
这使得StudentID工作但ClassID没有。我也尝试使用Classes(ClassID),但这不起作用。