Aqib Zaman
Aqib Zaman

Reputation: 285

MySQL error showing while creating table to make a relation with another by using foreign key

I have onetables empadd. Now i want to create an another table named leave that connects empadd to make a relation. But while doing this i get the below error,

code create table leave(LeaveId int not null auto_increment,LeaveType varchar(255),Department varchar(255),FromDate varchar(255),ToDate varchar(255),Days int,Reason varchar(255),primary key(LeaveId),foreign key(EmployeeId) references empadd(EmployeeId));

Error

Upvotes: 0

Views: 65

Answers (1)

D M
D M

Reputation: 1410

According to this page, leave is a reserved keyword in MySQL. You can use it if you put quotes around it, but you might want to consider changing the name of the table to something not reserved.

Upvotes: 0

Related Questions