Cannot add or update a child row: a foreign key constraint fails (`hw2`.`order_item`,?
- ✓Follow publicly
- ✓Follow privately
I'm trying to do an insert into my order_item table, but I'm getting this error. Can someone help with why this is happening. Thank you. My sql code to create the tables is ...show more
Did you do the insert into table 'orders' first? Because of the foreign key constraint, orders.id must be populated before attempting to populate order_item.order_id
No other answers
Ask a Question