6having

6having
点击领取淘宝京东拼多多唯品会优惠券

HAVING方法用于配合group方法完成从分组的结果中筛选(通常是聚合条件)数据。

having方法只有一个参数,并且只能使用字符串,例如:

Db::table('score')
    ->field('username,max(score)')
    ->group('user_id')
    ->having('count(test_time)>3')
    ->select(); 
复制

生成的SQL语句是:

SELECT username,max(score) FROM score GROUP BY user_id HAVING count(test_time)>3
复制

上一篇:6group

下一篇:6join