1.支持單條件或者多條件,查找重復(fù)記錄,語(yǔ)句:
where (a.state,a.org_id,a.material_id) in (select state,org_id,material_id from stock where state = 1 group by state,org_id ,material_id having count(*) > 1)
其中“a.state”、“a.org_id”、“material_id”,為條件查詢(xún),也就是這三個(gè)調(diào)件相同。
2.刪除重復(fù)記錄并且只留一條記錄
where (org_id,material_id,state) (select org_id,material_id, state from stock WHERE state = 1 group by org_id,material_id,state having count(*) > 1) (select min(stock_id) from stock where state = 1 group by org_id,material_id,state having count(*)>1) b
|