表billing
字段ID,配置号(config)..........N多个字段
现在需要查询,配置号重复的结果集要怎么写呢
select * from billing where id in
(
select id from billing group by config having count(config)>1
)-------------执行时间  9分钟
select * from billing as b1
inner join billing as b2
on b1.config = b2.config where count(b2.config)>1????????
大家帮帮我吧。

解决方案 »

  1.   

    select *
    from billing  A
    where exists (select 1 from billing  B where A.config =B.config and A.id<>B.id);
      

  2.   

    select * from billing a
    where exists (select 1 from billing where 字段ID!=a.字段ID and config=a.config)
      

  3.   

    select * from billing b
    where exists(select 1 from billing t where t.id<>b.id and a.config=t.configI);
      

  4.   

    select * from billing  A
    where exists (select 1 from billing where A.config =config and A.id<>id);在config、id上建立索引