日期:2014-05-19  浏览次数:20566 次

求条删除有重复的数据的语句

表1

mobile
10000
10000
20000
30000
30000
40000

我想用语句变成
表1

mobile
10000
20000
30000
40000

------解决方案--------------------
select distinct mobile # into #a from tablename
delete tablename
insert into tablename(mobile)
select mobile from #a
drop table #a
------解决方案--------------------
如果完全一樣只樓上的做法
------解决方案--------------------
delete form 表1 where mobile not in (select mobile from 表1 group by mobile)

或者用distinct mobile
如果只用第一位做判断就把所有的mobile换为left(mobile,1)