mysql查詢的方式很多,下面為您介紹的mysql 查詢實現的是查詢本週、上週、本月、上個月份的資料,如果您對mysql查詢方面感興趣的話,不妨一看。
查詢當前這週的資料
select name,submittime from enterprise where yearweek(date_format(submittime,'%y-%m-%d')) = yearweek(now());
查詢上週的資料
select name,submittime from enterprise where yearweek(date_format(submittime,'%y-%m-%d')) = yearweek(now())-1;
查詢當前月份的資料
select name,submittime from enterprise where date_format(submittime,'%y-%m')=date_format(now(),'%y-%m')
查詢距離當前現在6個月的資料
select name,submittime from enterprise where submittime between date_sub(now(),interval 6 month) and now();
查詢上個月的資料
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 下月第一天
sql server 查詢當前月份日期列表資料
select convert varchar 10 dateadd dd,number,dateadd dd,day getdate 1,getdate 120 as every time,日期datepart weekday,dateadd dd,number,dateadd dd,day get...
查詢MYSQL當前連線數
show processlist show full processlist show variables like max connections show status like connection mysql show status like threads variable name va...
mysql 當前排名查詢 mysql排名查詢
排名函式的型別 row number函式 不考慮並列名次的情況。比如前3名是並列的名次,row number函式排名之後是正常的1,2,3,4。通用的mysql排名解法 由於mysql8.0才有視窗函式解決排名問題,之前的版本需要自行實現排名函式,我寫了一些通用的sql套用以上的排名場景,以下sql...