第一条语句不加distinct我测试时和加是一样的。
第三种方法太复杂了,可简化如下:
select a.* from u_db a where idno+idtype in(select idno+idtype
from u_db group by idno,idtype having count(*) > 1 )
第三种方法太复杂了,可简化如下:
select a.* from u_db a where idno+idtype in(select idno+idtype
from u_db group by idno,idtype having count(*) > 1 )
(3)查询三中最终的条件语句中为什么会是where a.idno = b.idno and a.idtype = b.idtype
中实际想问的是如果是b.idno = a.idno and b.idtype = a.idtype是否可以
1.找出idtype + idno的重复组合.
2.iden可以唯一的标识一行.--第三种思路也可以这样写
select a.*
from u_db a,
(select idtype, idno from u_db group by idtype, idno having count(*) > 1) b
where a.idtype = b.idtype
and a.idno = b.idno