I have a table in MySQL 5.7.26 where I am storing history of products, I do not have any auto increment column
+------------+---------------------+
| product_id | date_in |
+------------+---------------------+
| 500 | 2020-04-24 07:10:52 |
| 500 | 2020-04-24 07:12:11 |
| 500 | 2020-04-24 07:16:25 |
| 500 | 2020-04-24 07:18:32 |
| 500 | 2020-04-24 07:18:42 |
| 500 | 2020-04-24 13:51:30 |
| 500 | 2020-04-24 14:01:22 |
| 501 | 2020-04-24 07:10:52 |
| 501 | 2020-04-24 07:12:11 |
| 501 | 2020-04-24 07:16:25 |
| 501 | 2020-04-24 07:18:32 |
| 501 | 2020-04-24 07:18:42 |
| 501 | 2020-04-24 13:51:30 |
| 501 | 2020-04-24 14:01:22 |
+------------+---------------------+
I want to keep only last 2 history rows per product, and delete all of them, so it will look like this
+------------+---------------------+
| product_id | date_in |
+------------+---------------------+
| 500 | 2020-04-24 13:51:30 |
| 500 | 2020-04-24 14:01:22 |
| 501 | 2020-04-24 13:51:30 |
| 501 | 2020-04-24 14:01:22 |
+------------+---------------------+