mysql 好用的sql语句
1.删除某个库里面全部的表 ,先在mysql库中执行: SELECT CONCAT('drop table ',table_name,';') FROM information_schema.`TABLES` WHERE table_schema='库名'; 在到相应的库里面执行上句执行得到的结果。 2.MySql按周,按月,按日分组统计数据 select DATE_FORMAT(create_time,'%Y%u') weeks,count(caseid) count from tc_case group by weeks; select DATE_FORMAT(create_time,'%Y%m%d') days,count(caseid) count from tc_case group by days; select DATE_FORMAT(create_time,'%Y%m') months,count(caseid) count from tc_case group by months; DATE_FORMAT(date,format) 根据format字符串格式化date值。下列修饰符可以被用在format字符串中: %M 月名字(January……December) %W 星期名字(Sunday……Saturday) %D 有英语前缀的月份的日期(1st, 2nd,