MySQL Forums
Forum List  »  Newbie

Error Code: 1452. Cannot add or update a child row
Posted by: K Sqlnicus
Date: January 01, 2015 02:25PM

I get error 1452:
Cannot add or update a child row: a foreign key constraint fails (`ap`.`invoices`, CONSTRAINT `invoices_fk_vendors` FOREIGN KEY (`vendor_id`) REFERENCES `vendors` (`vendor_id`) ON DELETE NO ACTION ON UPDATE NO ACTION)	0.000 sec

Query I tried to execute:
INSERT INTO invoices
  (vendor_id, invoice_number, invoice_date, 
   invoice_total, terms_id, invoice_due_date)
VALUES 
  (12, '3289175', '2011-07-18', 165, 3, '2011-08-17');

UPDATE invoices
SET credit_total = 35.89
WHERE invoice_number = '367447';

UPDATE invoices
SET invoice_due_date = DATE_ADD(invoice_due_date, INTERVAL 30 DAY)
WHERE terms_id = 4;


DELETE FROM invoices
WHERE invoice_number = '4-342-8069';

DELETE FROM invoices
WHERE invoice_total - payment_total - credit_total = 0;

Using XAMPP 1.8.3
Certificate: Cisco CCNA

Options: ReplyQuote


Subject
Written By
Posted
Error Code: 1452. Cannot add or update a child row
January 01, 2015 02:25PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.