Mysql
 sql >> Database >  >> RDS >> Mysql

Elimina i record da una tabella in cui

PROVA a selezionare il massimo ID raggruppa per db_type prima e poi usalo come sottoquery con not in .

 DELETE FROM MyTable 
 WHERE ID NOT IN 
    (SELECT ID FROM 
      (SELECT MAX(ID) AS ID from MyTable GROUP BY DB Type) AS tb1
    )

EDIT:

 DELETE FROM MyTable
 HAVING MAX(ID) > ID;