I have products table and I have duplicate records in the table according to `product_code`. Instead of deleting the old record I need to update the old record and keep the latest record as it. So here are how they look like in the table

```
id      product_code    Qty     Type    updatedDate                 addedDate
1       AB12            5       AB      2017-05-11 09:00:00         2017-05-11 09:00:00
2       CD12            4       AC      2016-05-11 09:00:00         2016-05-11 09:00:00     
3       EF12            5       AB      2016-05-11 09:00:00         2016-05-11 09:00:00
4       AB12            6       AB      2016-05-11 09:00:00         2016-05-11 09:00:00
5       GH12            5       AC      2016-05-11 09:00:00         2016-05-11 09:00:00
6       IJ12            6       AB      2016-05-11 09:00:00         2016-05-11 09:00:00
7       KL12            8       AB      2016-05-11 09:00:00         2016-05-11 09:00:00
8       EF12            10      AB      2017-05-11 09:00:00         2017-05-11 09:00:00
9       GH12            1       AC      2017-05-11 09:00:00         2017-05-11 09:00:00
10      MN12            3       AB      2016-05-11 09:00:00         2016-05-11 09:00:00

```

For all the old records according to `addedDate`, I need to set `Qty` to '0'. 

I selected the records from the following query but I need to update them with latest record. Here is the query

```
SELECT id, product_code, Qty, Type, updatedDate, addedDate 
FROM products WHERE Type = 'AB'
GROUP BY `product_code`
HAVING COUNT(`product_code`) > 1 ORDER BY `products`.`addedDate`

```