hellomello
hellomello

Reputation: 8587

MySQL errno 150 with foreign key

So I've been getting this error when I type this in:

ALTER TABLE user_follow
ADD FOREIGN KEY (follower,following)
REFERENCES users(idusers)

But I don't get an error when I separate the follower and the following

ALTER TABLE user_follow
ADD FOREIGN KEY (follower)
REFERENCES users(idusers)

ALTER TABLE user_follow
ADD FOREIGN KEY (following)
REFERENCES users(idusers)

Am I doing this correctly?

Upvotes: 1

Views: 78

Answers (1)

John Woo
John Woo

Reputation: 263723

Because you cannot reference multiple columns to one column of the other table. Below is an example on how you can define multiple compound foreign key

Upvotes: 2

Related Questions