select   Distinct    Mobile ,mesdst   from   TB_Mobile  上面是 我查询的 重复的数据 只显示一次  但是 我希望查询出整个表的信息。然后重复的数据只显示一次。

解决方案 »

  1.   

    select Distinct * from TB_Mobile  
      

  2.   

    select Mobile,mesdst from TB_Mobile  在你显示的时候处理。如何处理?跟的怎么显示有关系,
      

  3.   


    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
    */
      

  4.   

    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 allselect * from #tempselect * from #temp t where id=(select min(id) from #temp where t.Mobile=Mobile)
      

  5.   


    select * from TB_Mobile  where id in (
    select mind(id) from TB_Mobile  group by Mobile 
    )