sql查询重复数据
程序员文章站
2022-04-08 11:25:26
select * from t_contract_purchase t where t.purcontractid in (select purcontractid from...
select * from t_contract_purchase t where t.purcontractid in (select purcontractid from t_contract_purchase group by purcontractid having count(1)>1) and t.subcompanyid='****' order by t.purcontractid desc, t.purcharseid desc;
查询表t_contract_purchase中,所有purcontractid字段内容重复的数据,并把数据按照先按照purcontractid,再按照purcharseid 降序排列展示出来。
更加精简一点,可以将语句改成:
select * from t_contract_purchase t where (select count(*) from t_contract_purchase s where s.purcontractid=t.purcontractid)>1
上一篇: axios拦截设置和错误处理方法
下一篇: 我们分组玩的游戏 还记得吗