删除SQL里的重复记录出错了,想只保留一条怎么改?谢谢
我有一个字段出现很多重复的记录,现在想删除重复的记录,只想保留一条,下面删除重记录出错了,请问应该怎么写?谢谢大家。(没有分了,已经全部用上,谢谢)
MyConn.Open();
string delStr = "select * from 表名 group by 字段名 salary having count(*)>1";
OleDbCommand MyComd = new OleDbCommand(delStr, MyConn);
MyComd.ExecuteNonQuery();
MyConn.Close();
------解决方案--------------------string delStr = "delete * from 表名 group by 字段名 salary having count(*)>1";
------解决方案--------------------
--删除重复记录,留下ID最大的一条记录
delete t from [Nop_LocaleStringResource] t
where LocaleStringResourceID not in
(select MAX(LocaleStringResourceID) from [Nop_LocaleStringResource] where LanguageID=t.LanguageID and ResourceName=t.ResourceName and ResourceValue=t.ResourceValue)
------解决方案--------------------http://blog.csdn.net/anya/article/details/6407280