I have tables and some of the columns should be foreign key; how can I force this relationship?
ALTER TABLE tbl1 ADD CONSTRAINT fk_user_id FOREIGN KEY (user_id) references tbl2(user_id);
But it gives me the following error:
error code:1215: cannot add foreign key constraint!
What is the solution in this case?