DB->count() returning different value from count(DB->get())

后端 未结 2 645
悲&欢浪女
悲&欢浪女 2021-02-06 01:56

I have the simplest of queries that I\'m trying to run

DB::table(\'user_visits\')->groupBy(\'user_id\')->count();

But it\'s returning the

2条回答
  •  鱼传尺愫
    2021-02-06 02:35

    You may try this because the group by statement is executed after the count(Bug #26209):

    DB::table('user_visits')->distinct('user_id')->count('user_id');
    

    Another mySql answer here.

提交回复
热议问题