mysql - populating table keep getting error #1452 -
im getting following error when trying populate products table
1452 - cannot add or update child row: foreign key constraint fails (computer_wholesale
.products
, constraint products_ibfk_1
foreign key (supp_id
) references suppliers
(supp_id
))
this statement im using populate table
insert products (prod_id,prod_name,price,on_hand,supp_id) values ("dthp7710","hp desktop","499.99","5","kbc355"), ("dtcp2109","cp desktop","479.99","2","adt217"), ("dtcp2149","cp desktop","799.99","2","adt217"), ("ltpbv060","packbell mz35-v060","349.99","3","cps533"), ("ltcpc504","cp c504ea","429.99","3","adt217"), ("lttaa100","toshiba a100","492.99","4","cps533"), ("ltpbmz36","packbell mz36-t019","549.99","6","cps533 "), ("ltta0338","toshiba a100-338","599.99","5","fcl162 "), ("djhp1280","hp deskjet 1280","172.92","5","kbc355 "), ("djepr180","epson stylus r1800","318.89","3","fcl162"), ("a1hpc318","hp photosmart c3180","34.99","8","kbc355 "), ("a1hpf380","hp deskjet f380","39.99","8","kbc355 "), ("a1lx5470","lexmark x5470","49.99","4","fcl162"), ("a1ep6050","epson stylus dx6050","59.99","4","fcl162 ");
if tell me im doing wrong or give solution fix proble appreciated.
thanks
you have @ least 1 row in second(supplier )table i.e. child table referencing non-existent row in parent table.
you disable using --
set foreign_key_checks = 0;
Comments
Post a Comment