開發中常常會遇到因為數據存在多條導致查詢報錯的問題,下麵的方法一鍵解決此問題。 1.查詢重覆數據條數 select count(1) from tb_jf_order_drawcash where order_id in (select order_idfrom tb_jf_order_drawca ...
開發中常常會遇到因為數據存在多條導致查詢報錯的問題,下麵的方法一鍵解決此問題。
1.查詢重覆數據條數
select count(1) from tb_jf_order_drawcash
where order_id in (select order_id
from tb_jf_order_drawcash
group by order_id
having count(order_id) > 1)
2.刪除重覆數據
delete from tb_jf_order_drawcash
where order_id in (select order_id
from tb_jf_order_drawcash
group by order_id
having count(order_id) > 1)
and ROWID not in (select min(ROWID)
from tb_jf_order_drawcash
group by order_id
having count(*) > 1)