CREATE TABLE PeopleFruit (
Id int primary key auto_increment,
Fruit varchar(64),
People varchar(64),
CreatedAt date
);
INSERT INTO PeopleFruit (Id, Fruit, People, CreatedAt) VALUES
(1 ,'Apple', 'John', '2020-11-13'),
(2 ,'Banana', 'Katie', '2020-11-25'),
(3 ,'Kiwi', 'Sam', '2021-03-03'),
(4 ,'Apple', 'Katie', '2021-04-12'),
(5 ,'Apple', 'Katie', '2021-04-24'),
(6 ,'Apple', 'John', '2021-04-30'),
(7 ,'Banana', 'Sam', '2021-09-02'),
(8 ,'Banana', 'Katie', '2021-11-11'),
(9 ,'Apple', 'Sam', '2021-12-12'),
(10 ,'Kiwi', 'John', '2021-12-15');
DELETE PeopleFruit.*
FROM PeopleFruit
LEFT JOIN (SELECT MAX(Id) Id FROM PeopleFruit) MaxId USING(Id)
WHERE MaxId.Id IS NULL;
SELECT * FROM PeopleFruit;