订单数据库
id dan money
01 0001a 5
02 0001a 5
03 0001a 5
04 0001b 5
05 0001c 5
如何检测一个订单号是否是有重复的
如果有列出所有数据
如上列
列出
01 0001a 5
02 0001a 5
03 0001a 5
mysql语句该怎么写?
select * from tt t where exists (select 1 from tt where dan=t.dan and id !=t.id);
应该是关于数据库的问题:oracle:select * from t where dan in (select dan from t where having count(dan)>1 group by dan)。
恩,SELECT * from ssc_record WHERE types = 7 and dan1 in(SELECT dan1 from ssc_record GROUP BY dan1 HAVING count(1)>2)
这样查询起来好慢阿 数据量大就卡在那不会动了。
select id,dan,money,count(*) as num from ssc_record group by dan having num > 1