文章目录 查询某个表属于哪个数据库格式化日期为(2020-11-30格式)查询重复数据删除表中的重复数据查询表中的索引字段查询结果增加行号查询伪列删除表数据插入表删除表更新表数据按每天进行分类,找数据最多的前20天数据 查询某个表属于哪个数据库 SELECT table_schema FROM information_schema.TABLES WHERE table_name ='你的表名字' 格式化日期为(2020-11-30格式) select DATE_FORMAT('2020-11-30 11:26:35','%Y-%m-%d') 查询重复数据 select image_batch_id,count(*) as count from t_cust_compare_biztoken group by image_batch_id having count>1; 删除表中的重复数据 DELETE FROM 你的表名字 WHERE image_batch_id NOT IN ( SELECT dt.minno FROM ( SELECT MAX(image_batch_id) AS minno FROM 你的表名字 GROUP BY policy_code ) dt ); 查询表中的索引字段 show index from 你的表名字; 查询结果增加行号 Mysql编辑工具中使用(Navicat查询结果显示行号): select @rownum:=@rownum+1 as rownum,a.* from 你的表名字 a,(select @rownum:=0) t 查询伪列 select @rownum:=@rownum+1 as rownum, 表名字.* from (select @rownum:=0) temp, 表名字; 删除表数据 delete from 你的表名字 where xxx 插入表 Insert into 你的表名字(表字段) values (字段值) 删除表 drop table 表名称 更新表数据 Update 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值 按每天进行分类,找数据最多的前20天数据 select count(id) as num, DATE_FORMAT(insert_time,'%Y-%m-%d') as insertTime from 你的表名字 group by insertTime order by num desc limit 20