我正在尝试将accounts表中的accountID字段连接到customers表中的外键。到目前为止这是我的代码:
创建表如果不存在items(id int(6)unsigned NOT NULL,…
items
id
这是因为你的 customer 表包含一个 accountID 列但约束 NOT NULL 没有默认值。
customer
accountID
NOT NULL
因此,实际上这是导致问题的声明:
INSERT INTO `customers` (`customerID`, `firstName`, `lastName`, `address`) VALUES ('1', 'moshe', 'rubin', 'haifa'), ('2', 'tanya', 'shelomayev', 'netanya'), ('3', 'itamar', 'ofer', 'haifa');