mysql 查询当天所有重复数据

180it 2021-04-05 PM 40℃ 0条

select * from info
where to_days(time) = to_days(now()) and tel in (select tel from info group by tel having count(tel) > 1);

info 数据库表名
tel 为手机号

方法2:mysql 查询当天所有重复数据
select * from info where to_days(time) = to_days(now()) and id not in (

    select t.id from 
    (select max(id) as id from info  group by tel) as t
    );

delete from info where to_days(time) = to_days(now()) and id not in (

    select t.id from 
    (select max(id) as id from info  group by tel) as t
    );
支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

mysql 查询当天所有重复数据