I'm getting following error while i try to add foreign key to already created table by alter query as follows. There is two table usertype which contain usertypeid field as primary key and account table which has usertypeid which i want to be a foreign key.
I'm using the following query, and as I know the query is correct, but don't know why i'm getting this error.
alter table account add constraint fk_usertypeid foreign key usertypeid references usertype(usertypeid) on update cascade on delete cascade;
Following error occured while i try to execute query
#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 usertype(usertypeid) on update cascade on delete cascade' at line 1