我想删除表中重复的数据只留一条我应该怎么做??? delete from table where id not in(select max(id) from table group by name,class) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select * into #temp from 表 group by 列....delete 表insert 表 select * from #temp 呵呵!看错了! CrazyFor(Fan) 大侠是对的!delete from table where id not in(select max(id) from table group by name,class) 更正:delete from table where id not in(select max(id) from table group by name) TO: pengdali(大力) 更正:delete from table where id not in(select max(id) from table group by name)你这个语句只要Name相同就认为是重复记录,即不同班级的但人名相同的只会保留一个,显然不符合要求。 如果id是唯一标识,不同班级同名不能删的话那么delete a from table a,table b where a.id<b.id and a.name=b.name and a.class=b.class sql字符串截取 vb60用SQL如何连接到远程数据库.初学SQL,在线等. sql如何查找拥有相似2列的数据 odbc数据源连接mssql2005后出现超时已过期问题,请各大虾帮帮忙 SQL Server 2000客户端的新建SQL Server注册不成功? sql 数据提取 sql2008数据库 怎么选择啊 安装SQLSERVER时候的问题,大家帮我看看,谢谢 SQL Server存储过程问题,请帮帮忙! 可否调用储存过程在服务器上建立一个目录? 谁知道如何使用SQL语句将Sql2000中的某个表或者满足条件的一个表的数据导出成txt文件? 在B/S结构中如何获得本机IP地址
delete 表
insert 表 select * from #temp
delete from table where id not in(select max(id) from table group by name,class)
delete from table where id not in(select max(id) from table group by name)
更正:
delete from table where id not in(select max(id) from table group by name)你这个语句只要Name相同就认为是重复记录,即不同班级的但人名相同的只会保留一个,显然不符合要求。
delete a from table a,table b where a.id<b.id and a.name=b.name and a.class=b.class