新聞中心
MySQL查詢的方式很多,下面為您介紹的MySQL查詢實現(xiàn)的是查詢本周、上周、本月、上個月份的數(shù)據(jù),如果您對MySQL查詢方面感興趣的話,不妨一看。

在延津等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務理念,為客戶提供成都網(wǎng)站建設、成都做網(wǎng)站 網(wǎng)站設計制作按需定制設計,公司網(wǎng)站建設,企業(yè)網(wǎng)站建設,高端網(wǎng)站設計,全網(wǎng)整合營銷推廣,外貿(mào)營銷網(wǎng)站建設,延津網(wǎng)站建設費用合理。
查詢當前這周的數(shù)據(jù)
SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'%Y-%m-%d')) = YEARWEEK(now());
查詢上周的數(shù)據(jù)
SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'%Y-%m-%d')) = YEARWEEK(now())-1;
查詢當前月份的數(shù)據(jù)
select name,submittime from enterprise where date_format(submittime,'%Y-%m')=date_format(now(),'%Y-%m')
查詢距離當前現(xiàn)在6個月的數(shù)據(jù)
select name,submittime from enterprise where submittime between date_sub(now(),interval 6 month) and now();
查詢上個月的數(shù)據(jù)
select name,submittime from enterprise where date_format(submittime,'%Y-%m')=date_format(DATE_SUB(curdate(), INTERVAL 1 MONTH),'%Y-%m')
select * from `user` where DATE_FORMAT(pudate,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m') ;
select * from user where WEEKOFYEAR(FROM_UNIXTIME(pudate,'%y-%m-%d')) = WEEKOFYEAR(now())
select *
from user
where MONTH(FROM_UNIXTIME(pudate,'%y-%m-%d')) = MONTH(now())
select *
from [user]
where YEAR(FROM_UNIXTIME(pudate,'%y-%m-%d')) = YEAR(now())
and MONTH(FROM_UNIXTIME(pudate,'%y-%m-%d')) = MONTH(now())
select *
from [user]
where pudate between 上月***一天
and 下月***天
文章標題:MySQL查詢本周、上周、本月、上個月份的數(shù)據(jù)
轉(zhuǎn)載注明:http://fisionsoft.com.cn/article/coejscd.html


咨詢
建站咨詢
