Answers for "laravel case when"

SQL
2

use cases condition in sql query laravel

->selectRaw("shares.id AS share_id, users.id AS user_id , 
    shares.connected_user_id ,    
      shares.original_language_id, shares.image,
      users.first_name, users.last_name, users.email,
      locations.city, provinces.name, countries.code,
      locations.lat, locations.lng,
      shares.created_at,
      (CASE WHEN users.id = {$user} THEN 1 ELSE 0 END) AS is_user)")
    ->orderBy('shares.created_at', 'desc')
Posted by: Guest on June-21-2020
0

case inside laravel query

DB::table('ref')->select(['id','name',DB::raw('(case when (id > 17) then "yes" else "no" end) as present')])->get();
Posted by: Guest on August-13-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language