我是删除数据库里 有某些字段相同的记录只保留一个,这样怎么做?
- SQL code
DELETE FROM aFROM TollData AS a CROSS JOIN aWHERE EXISTS (SELECT 1 AS Expr1 FROM TollData WHERE (CardID = a.CardID) AND (StCardDate = a.starddate) AND (Balance = a.Balance))
------解决方案--------------------
- SQL code
delete from a where id not in (select max(id) from a group by CardID,StCardDate ,Balance )