I like to delete duplicates from a table game
. There are entries with the same playerId
and timeParameter
and the ones with lowest gameId
should remain.
I can query the entries with:
select a.`gameId` from `game` a
where not exists
(select min(b.`gameId`) as m from `game` b
group by b.`playerId`, b.`timeParameter`
having m = a.`gameId`);
But I can't use the alis a in the delete statement:
delete from `game` a
where not exists
(select min(b.`gameId`) as m from `game` b
group by b.`playerId`, b.`timeParameter`
having m = a.`gameId`);
Getting a syntax error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MariaDB server version for the right syntax to use near 'a
where not exists
(select min(b.`gameId`) as m from `game` b
group by b.`' at line 1
This error tells me nothing, but I know that I can't use aliases in a delete statement.
Is there a solution for this?