sql查询重复数据
程序员文章站
2024-01-16 16:19:47
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
上一篇: 微信web端后退强制刷新功能的实现代码
下一篇: 支付宝如何查询核酸检测报告的结果?