求购SQL语句

taia 2004-11-18 08:55:40
areaid areaname
1 合肥市
1 合肥市
2 芜湖市
2 芜湖市
4 北京市
4 北京市
6 安庆市
6 安庆市
7 巢湖市
7 巢湖市

怎样删除其中重复的另一条记录使之成为如下:

areaid areaname
1 合肥市
2 芜湖市
4 北京市
6 安庆市
7 巢湖市
...全文
88 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
davorsuker39 2004-11-19
  • 打赏
  • 举报
回复
select distinct * into #tab from tb
go
delete from tb
go
insert into tb select * from #tab
Ncaidexiaoniao 2004-11-19
  • 打赏
  • 举报
回复
create table aa(areaid int , areaname varchar(100))
insert aa select 1,'合肥市'
union all select 1,'合肥市'
union all select 2,'芜湖市'
union all select 2,'芜湖市'
union all select 4,'北京市'
union all select 4,'北京市'
union all select 6,'安庆市'
union all select 6,'安庆市'
union all select 7,'巢湖市'
union all select 7,'巢湖市'

select distinct * into #bb from aa
delete from aa
select * from #bb
drop table aa
drop table #bb
duanduan1122 2004-11-19
  • 打赏
  • 举报
回复
改动一下:
select distinct * into #tab from tb
go
delete from tb
go
insert into tb select * from #tab
ORARichard 2004-11-18
  • 打赏
  • 举报
回复
支持hdhai9451(※★開拓者...前進☆※)

楼主求购SQL,是付现金还是分分哦,(呵呵,开玩笑的)
zlp321002 2004-11-18
  • 打赏
  • 举报
回复
恩。可以!
Andy__Huang 2004-11-18
  • 打赏
  • 举报
回复
用臨時表過渡數據﹐轉換數據完后再刪除臨時表

select distinct * into tab from tb
delete from tb
insert into tb select * from tab
drop table tb
taia 2004-11-18
  • 打赏
  • 举报
回复
g

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧