I have the following tables:
CREATE TABLE IF NOT EXISTS
books(
book_idvarchar(50) NOT NULL,
book_titlevarchar(50) NOT NULL,
courseidvarchar(50) NOT NULL,FOREIGN KEY ('courseid') REFERENCES 'course'('course_id') ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS
course(
course_idvarchar(50) NOT NULL,
yearvarchar(50) NOT NULL,
sectionvarchar(50) NOT NULL,PRIMARY KEY (
course_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
I want to make courseid(under books table) a foreign key referencing course_id (under course table) but getting the following error message:
**#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 ''courseid') REFERENCES 'course'('course_id')
) ENGINE=InnoDB DEFAULT CHARS' at line 15**
I tired several syntax for declaring Foreign key (using CONSTRAINT FOREIGN KEY, with/without quotes etc) but none worked.
I am using Xamp WITH Server version: 5.5.32 - MySQL Community Server (GPL).
Can someone please help me with this issue?
Thanks