# Cannot delete or update a parent row

**URL:** <https://forum.codewithmosh.com/t/cannot-delete-or-update-a-parent-row/16469>\
**Category:** SQL\
**Created:** [November 15, 2022, 8:22am UTC](https://forum.codewithmosh.com/t/cannot-delete-or-update-a-parent-row/16469 "2022-11-15T08:22:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zhaoying](https://avatars.discourse-cdn.com/v4/letter/z/b5a626/32.png) [@Zhaoying](https://forum.codewithmosh.com/u/Zhaoying)\
**Post date:** [November 15, 2022, 8:22am UTC](https://forum.codewithmosh.com/t/cannot-delete-or-update-a-parent-row/16469/1 "2022-11-15T08:22:30Z")

</div>

Hi everyone, I just learned the SQL course section Inserting, Updating, and Deleting Data - 9- Deleting Rows. As Mosh showed at the end of the video (01:21), we can delete rows from invoices table where client name = ‘Myworks’. I change Mosh’s code from SELECT \* to SELECT client\_id, which I think is correct, and name = ‘Myworks’ to name = ‘Vinte’. The others are the same with Mosh’s coding. But when I executed the query, I received an error, which said ‘Error Code: 1451. Cannot delete or update a parent row: a foreign key constraint fails (`sql_invoicing`.`payments`, CONSTRAINT `fk_payment_invoice` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`invoice_id`) ON UPDATE CASCADE)’. Do you have any idea? Thanks in advance!
