如何在一个数据表中查 两个字段一样的记录集
table a
ID name type 三个字段
查 name 和type 内容都一样的记录集

解决方案 »

  1.   

    select * from tb where name = type
      

  2.   

    select t.* from a t where exists(select 1 from a where name=t.name and type=t.type and ID<>t.ID)
      

  3.   

    select * from a where Name=Type
    還是
    select  Name,Type from a t group by  Name,Type having count(1)>1
      

  4.   

    select * from tb where Name=Type
      

  5.   

    SELECT * FROM TB WHERE NAME=TYPE是不是这样?
      

  6.   

    select * from a where name=type
      

  7.   

    不是,是指 name 和type 两个字段都相同的记录集
      

  8.   


    select * from a 
    group by name,type 
    having count(1)>1
      

  9.   

    SELECT * FROM TB A WHERE EXISTS(SELECT 1 FROM TB WHERE NAME=A.NAME,TYPE=A.TYPE AND ID<>A.ID)