How To Display A User Determined By The Maximum Number Rows
I'm using laravel 4.2 and I have the following table that looks like this ID|chosen(boolean('0','1'))|subject|user_id 1|1 |cricket|2 2|0
Solution 1:
You are selecting the count only. Try this
$table = DB::table('tablename')
->select(DB::raw('count(user_id) AS CountUser, user_id'))
->where('chosen', 1)
->orderBy('CountUser', 'desc')
->groupBy('user_id')
->first();
Post a Comment for "How To Display A User Determined By The Maximum Number Rows"