Q: on duplicate key update doesnt update rather insert a row INSERT INTO min_product ( shopid, productid , outward ) 
SELECT shopid, productid , outward 
FROM main_product 
WHERE shopid= '51' 
    ON DUPLICATE KEY UPDATE outward  = ( SELECT sum(outward)  
                                         FROM main_product WHERE shopid= '51' )

main_product table
productid outward shopid
    333      2      44//present
    343      4      44//present
    353      5      44//present
    363      1      44//present
    373      2      44//not present

min_product table
productid outward shopid

333      1      44
343      1      44
353      1      44
363      1      44


the problem is that it doesnt update on duplicate row rather a new row is inserted ? what is the problem in the query ON DUPLICATE KEY UPDATE

A: If your database allows for the duplicate row to be inserted your table is not defined correct - Update is only performed if a duplicate of a UNIQUE index or PRIMARY KEY is inserted
INSERT ... ON DUPLICATE KEY UPDATE Syntax
