laravel count query code example

Example 1: group by laravel

$user_info = DB::table('usermetas')
                 ->select('browser', DB::raw('count(*) as total'))
                 ->groupBy('browser')
                 ->get();

Example 2: laravel not in query

DB::table(..)->select(..)->whereNotIn('book_price', [100,200])->get();

Example 3: laravel wher in

$users = DB::table('users')
                    ->whereIn('id', [1, 2, 3])
                    ->get();

Example 4: DB::table('users')->get();

$users = DB::table('users')->get();

Example 5: laravel select count

$count = DB::table('category_issue')->count();

Tags:

Sql Example