随笔分类 -  mysql

摘要:thinkphp5示例: //子查询主要的在MAX(create_time) $subQuery = Db::table('fa_crm_record') ->field('customer_id,MAX(create_time) AS create_time') ->group('customer 阅读全文
posted @ 2023-10-24 17:55 亚索会代码 阅读(982) 评论(0) 推荐(0)
摘要:如果你的表是按年份命名的,例如 table_2021, table_2022, table_2023, table_2024, table_2025,你可以考虑使用分区查询来优化查询性能 SELECT * FROM table_2021 UNION ALL SELECT * FROM table_2 阅读全文
posted @ 2023-08-31 11:31 亚索会代码 阅读(101) 评论(0) 推荐(0)
摘要:<?php //根据日期来统计所消耗的点数 //模型的使用方法 $result = $model ->field("id,FROM_UNIXTIME(createtime,'%Y-%m-%d') as `createtime`,sum(price) as count_price") ->group( 阅读全文
posted @ 2023-08-29 17:14 亚索会代码 阅读(499) 评论(0) 推荐(0)