ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
> `groupby`用于对数据集合进行分组,例如: ```php //查询订单表中每个用户的订单总额 Db('order')->select([ 'field' => ['SUM(OrderPrice) as Price','userId'], 'groupby' => 'userId' ])->get(); //sql:SELECT SUM(OrderPrice) as Price,`userId` FROM `order` GROUP BY userId; ``` >SQL小技巧:对于查询频率高的多数据表,建立字段索引将大大提高查询速度