[英]What does error 1452 “a foreign key constraint fails” during an insert mean?
So I am trying to add information to a table in phpMyAdmin, but it will not let me 'add or update a child row' with error code #1452.所以我试图将信息添加到 phpMyAdmin 中的表中,但它不会让我“添加或更新子行”,错误代码为 #1452。
INSERT INTO tblBooking (BookingRef, AppRef, BookingDate, TableNo, Verified, VerifyStaffID, bPassword)
VALUES ('1', '1', '2021-03-05', 'Table 1', 'Y', '2', 'Password123'),
('2', '1', '21-01-07', 'Table 2', 'N', '3', 'Chain'),
('3', '2', '20-11-02', 'Table 3', 'Y', '1', 'aSecret'),
('4', '3', '20-12-06', 'Table 2', 'Y', '4', 'Pedal')
I get this error:[error description]我收到此错误:[错误描述]
Thanks in advance.提前致谢。
MYSQL is complaining about a FK that doesn't exists in the parent table, so in your case one or more than one of the VerifyStaffID values ( 1, 3, 4) doesn't exists in the parent table (tblstaff) MYSQL 抱怨父表中不存在 FK,因此在您的情况下,父表 (tblstaff) 中不存在一个或多个 VerifyStaffID 值(1、3、4)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.