如果你要严格要求是某一年的,那可以这样 查询一天: select * from table where to_days(column_time) = to_days(now()); select * from table where date(column_time) = curdate(); 查询一周: DAY) <= date(column_time); 查询一个月: select * from table where DATE_SUB(CURDATE(), INTERVAL 1 MONTH…
select * from wap_content where week(created_at) = week(now) 如果你要严格要求是某一年的,那可以这样 查询一天: select * from table where to_days(column_time) = to_days(now());select * from table where date(column_time) = curdate(); 查询一周: select * from table where DATE_SUB(C…
本周内:select * from wap_content where week(created_at) = week(now) 查询一天:select * from table where to_days(column_time) = to_days(now());select * from table where date(column_time) = curdate(); 查询7天:select * from table  where DATE_SUB(CURDATE(), INTERVA…
本周内:select * from wap_content where week(created_at) = week(now) 查询一天:select * from table where to_days(column_time) = to_days(now());select * from table where date(column_time) = curdate(); 查询7天:select * from table  where DATE_SUB(CURDATE(), INTERVA…
SELECT ID,SERVICE FROM new_schedules_spider_full WHERE SERVICE = 'WSA2' and date_sub(curdate(), interval 7 day) <= date(CREATE_TIME);…
MySQL查询近一个月的数据 近一个月统计SQL select user_id, user_name, createtime from t_user where DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= date(createtime); 同理,近一个星期为: INTERVAL 7 DAY. @完…
在mysql中查询不区分大小写重复的数据,往往会用到子查询,并在子查询中使用upper函数来将条件转化为大写.如: select * from staticcatalogue WHERE UPPER(Source) IN (SELECT UPPER(Source) FROM staticcatalogue GROUP BY UPPER(Source) having count(UPPER(Source))>1) ORDER BY upper(Source) DESC; 这条语句的执行效率是非常低…
查询某个字段重复的数据 ; 查询股票重复的营业厅 ;…
1.查询当天的数据 select * from 表名 where TO_DAYS(时间字段)=TO_DAYS(NOW()); 2.查询当周的数据 select * from 表名 where YEARWEEK(DATE_FORMAT(时间字段,'%Y-%m-%d'))=YEARWEEK(NOW()); 3.查询当月的数据 select * from 表名 where DATE_FORMAT(时间字段,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m'); 4.查询昨天的数据…
常用计算日期的函数 日 date(日期) = CURDATE() 自然周 YEARWEEK(date_format(日期,'%Y-%m-%d') , 1) = YEARWEEK(now() , 1) 月 DATE_FORMAT( 日期, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' ) 计算周的原理 MySql计算周的函数有两个,一个是YEARWEEK(date, mode)一个是WEEK(date, mode) 他们的原理都是通过计算当前日期是属于一年…