MySQL Creating tables with Foreign Keys giving errno: 150

前端 未结 20 2411
深忆病人
深忆病人 2020-11-21 05:02

I am trying to create a table in MySQL with two foreign keys, which reference the primary keys in 2 other tables, but I am getting an errno: 150 error and it will not create

20条回答
  •  花落未央
    2020-11-21 05:33

    Please make sure at first that

    1. you are using InnoDB tables.
    2. field for FOREIGN KEY has the same type and length (!) as source field.

    I had the same trouble and I've fixed it. I had unsigned INT for one field and just integer for other field.

提交回复
热议问题