【SQL查询 重复数据只显示一次】

随心录123 2011-08-23 12:27:03
select Distinct Mobile ,mesdst from TB_Mobile

上面是 我查询的 重复的数据 只显示一次

但是 我希望查询出整个表的信息。然后重复的数据只显示一次。
...全文
1327 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
coder_s 2011-08-23
  • 打赏
  • 举报
回复

select * from TB_Mobile where id in (
select mind(id) from TB_Mobile group by Mobile
)
huangwenquan123 2011-08-23
  • 打赏
  • 举报
回复
create table #temp(id int,Mobile varchar(50),mesdst varchar(30))
insert into #temp
select 1,'11','a' union all
select 2,'11','b' union all
select 3,'22','a' union all
select 4,'22','b' union all
select 5,'22','c' union all
select 6,'33','a' union all
select 7,'33','b' union all

select * from #temp

select * from #temp t where id=(select min(id) from #temp where t.Mobile=Mobile)
叶子 2011-08-23
  • 打赏
  • 举报
回复

declare @TB_Mobile table (id int,Mobile int,mesdst int,other varchar(1))
insert into @TB_Mobile
select 1,139139,77,'a' union all
select 2,139139,77,'b' union all
select 3,139139,77,'c' union all
select 4,139132,77,'d' union all
select 5,139132,77,'e' union all
select 6,139133,77,'f' union all
select 7,139134,77,'g' union all
select 8,139134,77,'h'

select * from @TB_Mobile a
where id=(select min(id) from @TB_Mobile
where Mobile=a.Mobile and mesdst=a.mesdst)
order by id
/*
id Mobile mesdst other
----------- ----------- ----------- -----
1 139139 77 a
4 139132 77 d
6 139133 77 f
7 139134 77 g
*/
孟子E章 2011-08-23
  • 打赏
  • 举报
回复
select Mobile,mesdst from TB_Mobile

在你显示的时候处理。如何处理?跟的怎么显示有关系,
随心录123 2011-08-23
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 yankai159357 的回复:]
引用 1 楼 maco_wang 的回复:
SQL code
select Distinct * from TB_Mobile


我还要 重复的数据 只显示一次 。
[/Quote]
针对 这个 字段 Mobile (电话号码字段)
随心录123 2011-08-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 maco_wang 的回复:]
SQL code
select Distinct * from TB_Mobile
[/Quote]

我还要 重复的数据 只显示一次 。
叶子 2011-08-23
  • 打赏
  • 举报
回复
select Distinct * from TB_Mobile  

62,250

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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