服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - PHP教程 - PHP文章按日期(月日)SQL归档语句

PHP文章按日期(月日)SQL归档语句

2020-01-20 16:05PHP教程网 PHP教程

PHP文章按日期(月日)SQL归档PHP文章按日期(月)SQL归档实现语句,需要的朋友可以参考下

代码如下:


select FROM_UNIXTIME(pubtime, '%Y-%m') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m') 


PHP文章按日期(日)SQL归档 

复制代码代码如下:


select FROM_UNIXTIME(pubtime, '%Y-%m-%d') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m-%d') 


非时间戳日期格式归档(date_format格式化日期) 

复制代码代码如下:


select date_format(`post_date`,'%Y%m%d') as pubtime, count(*) as cnt from wp_posts where `post_status`='publish' group by date_format(`post_date`,'%Y%m%d') order by `ID` desc 
select date_format(`post_date`,'%Y%m%d') as pubtime,date_format(`post_date`,'%m 月 %d 日') as shijian,count(*) as cnt from wp_posts where `post_status`='publish' group by date_format(`post_date`,'%Y%m%d') order by `ID` desc limit 0,7 

延伸 · 阅读

精彩推荐