《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
关于 LearnKu
不是用 group 就好了吗?
使用
DISTINCT 用户ID使用 keyBy(' 用户ID ')
试试跟据from_user_id分组获得本组最大自增id,然后再in出来呢。数据量大可能会是个坑,但如果每日几万条数据应该是没问题的,配合created_at索引使用。
增加一个字段 is_user_latest, 代表是否这个用户最新一条评论
就 OK 了
https://github.com/staudenmeir/eloquent-ea...
SELECT max(created_at),from_user_id,content from messages WHERE created_at like "%2019-08-21%" GROUP BY from_user_id ORDER BY from_user_id desc limit 100;
不知道这个能适应你的需求不;
关于group by组内排序的问题,mysql官方文档有讲
https://dev.mysql.com/doc/refman/5.6/en/gr...
MySQL extends the standard SQL use of GROUP BY so that the select list can refer to nonaggregated columns not named in the GROUP BY clause. This means that the preceding query is legal in MySQL. You can use this feature to get better performance by avoiding unnecessary column sorting and grouping. However, this is useful primarily when all values in each nonaggregated column not named in the GROUP BY are the same for each group. The server is free to choose any value from each group, so unless they are the same, the values chosen are nondeterministic. Furthermore, the selection of values from each group cannot be influenced by adding an ORDER BY clause. Result set sorting occurs after values have been chosen, and ORDER BY does not affect which values within each group the server chooses.结论就是除非记录完全相同,否则mysql 不保证每次group by结果相同
我这样做,效果已达到。