查询一个表内相同纪录 无 select?*?from?表?where?ID?in?(select?ID?from?表?group?by?ID?having?sum(1)1) select?*?from?表?where?ID1+ID2+ID3?in(select?ID1+ID2+ID3?from?表?group?by?ID1,ID2,ID3?having?sum(1)1) –方法1:????SELECT??*FROM??zy_bho??a
查询一个表内相同纪录
<style> .CodeEntity .code_pieces ul.piece_anchor{width:25px;position:absolute;top:25px;left:-30px;z-index:1000;} .CodeEntity .code_pieces ul.piece_anchor li{width:25px;background: #efe;margin-bottom:2px;} .CodeEntity .code_pieces ul.piece_anchor li{border-left:3px #40AA63 solid;border-right:3px #efe solid;} .CodeEntity .code_pieces ul.piece_anchor li:hover{border-right:3px #40AA63 solid;border-left:3px #efe solid;} .CodeEntity .code_pieces ul.piece_anchor li a{color: #333;padding: 3px 10px;} .CodeEntity .code_pieces .jump_to_code{visibility:hidden;position:relative;} .CodeEntity .code_pieces .code_piece:hover .jump_to_code{visibility:visible;} .CodeEntity .code_pieces .code_piece:hover .jump_to_code a{text-decoration:none;} .CodeEntity .code_pieces h2 i{float:right;font-style:normal;font-weight:normal;} .CodeEntity .code_pieces h2
i a{font-size:9pt;background: #FFFFFF;color:#00A;padding: 2px 5px;text-decoration:none;} </style> <!—ecms
- –> <!—ecms
- $velocityCount
–> <!—ecms
–>
select?*?from?表?where?ID?in?(select?ID?from?表?group?by?ID?having?sum(1)>1)
select?*?from?表?where?ID1+ID2+ID3?in(select?ID1+ID2+ID3?from?表?group?by?ID1,ID2,ID3?having?sum(1)>1)
--方法1:????SELECT??*FROM??zy_bho??a??WHERE??EXISTS???(SELECT??1??FROM??zy_bho??WHERE??[PK]????a.[PK]??AND??ZYH??=??a.ZYH)????--方法2:select??a.*??from??zy_bho??a??join??zy_bho??b???????on??(a.[pk]b.[pk]??and??a.zyh=b.zyh)????--方法3:select??*??from??zy_bbo??where??zyh??in?(select??zyh??from??zy_bbo??group??by??zyh??having??count(zyh)>1)?--其中pk是主键或是?unique的字段。