How can I write a query that will get the first active game_id that does not occur twice in the table below?
2
This will only show all the game id and the number of their occurences
$user_info = DB::table('usermetas') ->select('browser', DB::raw('count(*) as total')) ->groupBy('browser') ->get();
How about :
DB::table('tablename') ->select(DB::raw('COUNT(game_id) as totalgames, game_id')) ->where('is_active', 1) ->groupBy('game_id') ->havingRaw('COUNT(game_id) = 1') ->first();
Click here to cancel reply.
2
Answers
This will only show all the game id and the number of their occurences
How about :