子查询中a.name想表示外层的字段, 实际因为表名是A, 所以还是指内层表了

解决方案 »

  1.   

    你把A的别名小a改为其它字母就可以了select * from A aaaa
    where exists  (select  name  from A where name=aaaa.name group by name having count(*)>1)
      

  2.   


    select * from A aa
    where (select count(*) from A where name=aa.name)>1
    --或者:
    select a.* from A join(select name from A group by name having count(*)>1) b on a.name=b.name
      

  3.   

    select * from A a
    where exists  (select  b.name  from A b where b.name=a.name group by b.name having count(*)>1)
      

  4.   

    select * from A a
    where exists  (select  b.name  from A b where b.name=a.name group by b.name having count(*)>1)