MySQL Forums
Forum List  »  Newbie

Trouble adding foreign key
Posted by: Edgar Leung
Date: August 22, 2019 02:43PM

I am currently trying to add a foreign key constraint but keeps giving me error:

------------------------------------------------
ERROR 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 ')
REFERENCES `warhammer`.`ideas` ()
ON DELETE NO ACTION
ON UPDATE CASCADE' at line 3
SQL Statement:
ALTER TABLE `warhammer`.`cost`
ADD CONSTRAINT `ideaUpdate`
FOREIGN KEY ()
REFERENCES `warhammer`.`ideas` ()
ON DELETE NO ACTION
ON UPDATE CASCADE

------------------------------------------------------

The alter table statement is:

------------------------------------------------------

ALTER TABLE `warhammer`.`cost`
CHANGE COLUMN `idea` `idea` VARCHAR(45) NOT NULL ;
ALTER TABLE `warhammer`.`cost`
ADD CONSTRAINT `ideaUpdate`
FOREIGN KEY ()
REFERENCES `warhammer`.`ideas` ()
ON DELETE NO ACTION
ON UPDATE CASCADE;

-------------------------------------------------------

Options: ReplyQuote


Subject
Written By
Posted
Trouble adding foreign key
August 22, 2019 02:43PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.