Maison  >  Article  >  développement back-end  >  PHP文章按日期(月日)归档的sql语句

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

WBOY
WBOYoriginal
2016-07-25 09:03:511119parcourir
  1. select FROM_UNIXTIME(pubtime, '%Y-%m') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m')
复制代码

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

  1. select FROM_UNIXTIME(pubtime, '%Y-%m-%d') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m-%d')
复制代码

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

  1. 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

  2. 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

复制代码


Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn