日期:2014-05-18  浏览次数:20389 次

这条语句有什么错误啊?
我是删除数据库里 有某些字段相同的记录只保留一个,这样怎么做?
SQL code

DELETE FROM a
FROM         TollData AS a CROSS JOIN
                      a
WHERE     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 )