2021-09-18 逃离我推掉我的手 2022-09-12 01:43 149阅读 0赞 [thinkphp5 sql 语句group+date\_format(time) 组合排序筛选数据\_hexiaoniao的博客-CSDN博客有需求要整合某时间范围内如:2019-09-21-2019-09-27 范围内的刷卡记录、每天只取最早的那天。来做判断所以这里要用到分组了。按照日期分组。上代码:record\_time为刷卡时间$db = Db::table(“表名”)->group("date\_format('record\_time','%m-%d-%Y')")->select();这样就搞定了。...![favicon32.ico][]https://blog.csdn.net/hexiaoniao/article/details/101520890][thinkphp5 sql _group_date_format_time_ _hexiaoniao_-CSDN_2019-09-21-2019-09-27 _record_time_db _ Db_table_-_group_date_format_record_time_m-_d-_Y_-_select_..._favicon32.ico_https_blog.csdn.net_hexiaoniao_article_details_101520890] \-------------------------------------------------------自己项目-------------------------------------------------------------- 数据库: ![80e9e0bcc26bb9c7e33b0fb791a63a3b.png][] //登陆天数 $data['data'][$k]['sum_online_data'] = Db::name('log_jjcp_login') ->where('userid',$v['userid']) ->group("date_format(loginTime,'%m-%d-%Y')") ->count(); ![b6658ab34d0b9a8bba6642ce73501f99.png][] [favicon32.ico]: /images/20220828/18b6c35bf5f54eb98dd91833246ce396.png [thinkphp5 sql _group_date_format_time_ _hexiaoniao_-CSDN_2019-09-21-2019-09-27 _record_time_db _ Db_table_-_group_date_format_record_time_m-_d-_Y_-_select_..._favicon32.ico_https_blog.csdn.net_hexiaoniao_article_details_101520890]: https://blog.csdn.net/hexiaoniao/article/details/101520890 [80e9e0bcc26bb9c7e33b0fb791a63a3b.png]: /images/20220828/e8471990f43846bda0d2578f2bce511d.png [b6658ab34d0b9a8bba6642ce73501f99.png]: /images/20220828/07f8a57978434e9e9d77a9523bbec4e8.png
还没有评论,来说两句吧...