Excuse me, someone could guide me with a problem I had when creating a table association since I created two tables (product (product_code, name, detail, existence), purchase_detail (purchase_code, product_code, detail, quantity)) and when wanting to register a purchase in detail_buy using a code_product already existing and to add the quantity in stock of the product table to it, as long as the product_code that is entered in detail_product is equal to the product table but I get this error :
Error
consulta SQL:
INSERT INTO detalle_compra values(1,2,'peces',5)
MySQL ha dicho:
#1062 - Entrada duplicada '1' para la clave 'PRIMARY'
and I'm trying to do that procedure with this code:
INSERT INTO detalle_compra values(1,2,'peces',5);
UPDATE producto SET producto.codigo_producto=detalle_compra.codigo_producto+1
WHERE producto.codigo_producto=detalle_compra.codigo_producto
and I have modified it many times to achieve it but I do not have it left maybe someone can help me, thanks in advance!