查询当天(今天)的数据
SELECT * FROM `order` WHERE TO_DAYS(order_time) = TO_DAYS(NOW())
查询昨天的数据
SELECT * FROM `order` WHERE TO_DAYS(NOW()) - TO_DAYS(order_time) = 1
查询最近7天的数据(包括今天一共7天)
SELECT * FROM `order` where DATE_SUB(CURDATE(), INTERVAL 7 DAY) < date(order_time)
查询最近30天的数据(包括今天一共30天)
SELECT * FROM `order` where DATE_SUB(CURDATE(), INTERVAL 30 DAY) < date(order_time)
查询当月(本月)的数据
SELECT * FROM `order` WHERE DATE_FORMAT(order_time, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')
查询上个月的数据
SELECT * FROM `order` WHERE PERIOD_DIFF(DATE_FORMAT(NOW(),'%Y%m'), DATE_FORMAT(order_time,'%Y%m')) =1
查询本季度的数据
SELECT * FROM `order` WHERE QUARTER(order_time)=QUARTER(NOW())
查询上季度的数据
SELECT * FROM `order` WHERE QUARTER(order_time)=QUARTER(DATE_SUB(NOW(),INTERVAL 1 QUARTER))
查询当年(今年)的数据
SELECT * FROM `order` WHERE YEAR(order_time)=YEAR(NOW())
查询去年的数据
SELECT * FROM `order` WHERE YEAR(order_time)=YEAR(DATE_SUB(NOW(),INTERVAL 1 YEAR))
查询当前这周的数据
SELECT * FROM `order` WHERE YEARWEEK(date_format(order_time,'%Y-%m-%d')) = YEARWEEK(now())
查询上周的数据
SELECT * FROM `order` WHERE YEARWEEK(date_format(order_time,'%Y-%m-%d')) = YEARWEEK(now())-1
查询当前月份的数据
select * from `order` where date_format(order_time,'%Y-%m')=date_format(now(),'%Y-%m')
查询距离当前现在6个月的数据
select * from `order` where order_time between date_sub(now(),interval 6 month) and now()
查询上个月的数据
select * from `order` where date_format(order_time,'%Y-%m')=date_format(DATE_SUB(curdate(), INTERVAL 1 MONTH),'%Y-%m')
相关阅读
MYSQL查询今天的数据(以及昨天、本月、上个月、最近7天、上季度)
2017-05-191005
查询当天(今天)的数据SELECT * FROM `order` WHERE TO_DAYS(order_time) = TO_DAYS(NOW())查询昨天的数据SELECT * FROM `order` WHERE TO_DAYS(NOW()) - TO_DAYS(order_time) = 1查询最近7天的数据(包括今天一共7天)SELECT * FROM `order` where DATE_SUB(CURDATE(), INTERVAL 7 DAY) < date(order_time)查询最近30天的数据
thinkphp常用入门的方法语句
2019-03-211060
setInc、setDec方法$User = M("User"); // 实例化User对象$User->where('id=5')->setInc('score',3); // 用户的积分加3$User->where('id=5')->setInc('score'); // 用户的积分加1$User->where('id=5')->setDec('score',5); // 用户的积分减5$User->where('id=5
文件后缀与Mime类型对照表
2017-05-191062
3gp video/3gppaab application/x-authoware-binaam application/x-authoware-mapaas application/x-authoware-segai application/postscriptaif audio/x-aiffaifc audio/x-aiffaiff audio/x-aiffals audio/X-Alpha5amc application/x-mpegani application/octet-streamasc text/plainasd application/astoundasf video/x-ms-asfasn application/astoundasp application/x-asap
iphone中的Mime类型对照表
2017-05-191023
.323text/h323Internet Telephony .aacaudio/aacAAC audio file .abwapplication/abiwordAbiWord document .acxapplication/internet-property-streamAtari ST Executable .aiapplication/illustratorAdobe Illustrator file .aifaudio/aiffAIFF audio fileaudio/aifc, audio/x-aiff.aifcaudio/aiffAIFF audio fileaudio/aifc, audio/x-aiff.aiffaudi