Thinkphp使用having查詢重復(fù)的數(shù)據(jù)
having方法只有一個參數(shù),并且只能使用字符串
例如:
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一般having需要group配合同時使用
評論
圖片
表情
