select * from tb
where tel in(select tel from tb group by tel having count(*)>1)

解决方案 »

  1.   

    [code=SQL]create table tb(id int,[name] nvarchar(10),code varchar(11))
    insert into tb select 1 ,'张三','13579123456' union all
    select 2,'李四','13579111111' union all
    select 3,'李四','13579111111'  union all
    select 4,'王五','13579222222'  union all
    select 6,'赵六','13579333333'  union all
    select 7,'赵六','13579333333'  union all
    select 8,'蔡七','13579444444'
    select * from tb a where [name]+code=(select [name]+code  from tb where [name]+code =a.[name]+a.code group by [name]+code having count(*)>1)
    drop table tb
    /*
    id          name       code
    ----------- ---------- -----------
    2           李四         13579111111
    3           李四         13579111111
    6           赵六         13579333333
    7           赵六         13579333333
    */
    code]
      

  2.   

    select distinct * from tb a where exists(select 1 from tb where col2=a.col2 and col3=a.col3 and col1<>a.col1 )
      

  3.   

    select  * from tb a where exists(select 1 from tb where col2=a.col2 and col3=a.col3 and col1<>a.col1 )
      

  4.   

    先多谢上面几位网友。但都不能出现我最想要的结果。
    我把6楼的改了一下:select  * from tb a where exists(select 1 from tb where col2=a.col2 and (sn=a.sn+1 or sn+1=a.sn))这样就可以出现连续的多于的记录的结果了。
    因为那些输入的人经常是连接按几次保存。
      

  5.   

    楼上那个
    select 1 from tb where col2=a.col2 and (sn=a.sn+1 or sn+1=a.sn))
    其中那个“1”是什么意思 还有这个(sn=a.sn+1 or sn+1=a.sn)指什么啊
    我不太懂