![]() ![]() ![]() You need a reference field for the user id in the payment table, too. Can anyone recognise where the problem is coming from?Īll help is very much appreciated, and thanks in advance. ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin (`Unique ID`) ON DELETE CASCADE ON UPDATE CASCADE `Trade Reference 2` varchar(100) NOT NULL,ĬONSTRAINT `Users_ibfk_1` FOREIGN KEY (`Unique ID`) REFERENCES `Payment Info` `Trade Reference 1` varchar(100) NOT NULL, `Registered Office` varchar(100) NOT NULL, ![]() `Nature of Business` varchar(20) NOT NULL, `Delivery Address` varchar(100) NOT NULL, `Unique ID` int(11) NOT NULL auto_increment, Ok, Below are the two outputs of those commands: The insert statement I am using is as follows: When I was trying to insert the data to see if the foreign key was working or not, that's when I got the error message posted previously. business name = varchar and 20 characters size limit, etc). I was just trying to insert any old sample data, which still falls into the constraints of each field (e.g. It wont let me add anything because of that error. This is for my full time job so please could you reply ASAP. Please can you help, or please can you let me know if you need any more information before you can solve the problem. "#1452 - Cannot add or update a child row: a foreign key constraint fails (`package5_PPS/Users`, CONSTRAINT `Users_ibfk_1` FOREIGN KEY (`Unique ID`) REFERENCES `Payment Info` (`Unique ID`) ON DELETE CASCADE ON UPDATE CASCADE)" The Unique ID field in both tables are supposed to link both sets of records.īoth tables are set up using the InnoDB engine and I have tried to set up the Foreign Key but it wont work, here is the error message I'm getting: I have added a unique ID field (along with other fields) in Users AND Payment Info. I have created and set up a MySQL database, and have created two tables ("Users" and "Payment Info"). First of all let me just tell you that I have never done database programming myself, and this is the first time I'm setting up a MySQL database via phpMyAdmin, so I could be missing something small but I'm sure someone will know the answer, anyways. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |