sql - How to display a user determined by the maximum number rows -
i'm using laravel 4.2 , have following table looks this id|chosen(boolean('0','1'))|subject|user_id 1|1 |cricket|2 2|0 |cricket|3 3|1 |rugby |2 i choose user_id has chosen rows or in other words user has 1s in chosen column. in case user 2 correct result. i believe answer $table = db::table('tablename') ->select(array(db::raw('count(user_id) countuser'))) ->where('chosen', 1) ->orderby('countuser', 'desc') ->groupby('user_id') ->first(); however how display user_id in view? example: {{$table->user_id}} //should give me '2' error message reads: undefined property: stdclass::$user_id you selecting count only. try this $table = db::table('tablename') ->select(db::raw('count(user_id) countuser, user_id')) ->where('c...