mysql 语句备忘

来源:互联网 发布:mac山狮系统 编辑:程序博客网 时间:2024/06/06 01:53

查找demo_20130427_wsdl 表中 ccid 重复的字段

select ccid,count(*)from demo_20130427_wsdl GROUP BY ccid HAVING COUNT(*)>1


查找test表中sku字段重复记录最多的前3条并统计数据

select *,count(`sku`) as count from `test` group by `sku` order by count desc limit 3

查找test表中1月份sku字段重复记录最多的前3条并统计数据

select *,count(`sku`) as count from `test` where `update_time` between  UNIX_TIMESTAMP('2014-01-01 00:00:00') and UNIX_TIMESTAMP('2014-01-31 00:00:00') group by `sku` order by count desc limit 3