MySQL Forums
Forum List  »  New in 4.1: Subqueries

Re: Problem with Nested Inserts
Posted by: Juan Javaloyes
Date: July 27, 2005 12:23PM

I'm going to give the exact case. Got two tables.
prod_suc: @id_suc, @id_prod, cod_prod, cantidad, stockini, precio1, precio2
prod_cant: @codigo, stock, preciom, preciom2

All rows on prod_suc are full, except cantidad, stockini, precio1, precio2. These are the columns I want to fill with data from prod_cant, where prod_suc.cod_prod = prod_cant.codigo.

INSERT INTO prod_suc (cantidad, stockini, precio_may1, precio_may2)
SELECT stock, stock, preciom, preciom2
FROM prod_cant
INNER JOIN prod_suc
ON prod_cant.codigo = prod_suc.cod_prod

Result: #1216 - Cannot add or update a child row: a foreign key constraint fails

Options: ReplyQuote


Subject
Views
Written By
Posted
5987
July 26, 2005 04:23PM
3315
July 26, 2005 06:59PM
Re: Problem with Nested Inserts
2947
July 27, 2005 12:23PM
3600
July 27, 2005 01:21PM
3212
July 27, 2005 02:11PM
3154
July 27, 2005 03:32PM


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.