Rahul Vp Rahul Vp - 9 months ago 45
MySQL Question

How to write normal sql query into laravel 5.2 format

How to write my sql query in laravel 5.2, query is giving below

SELECT a.groupID, count( * ) AS totalCount, b.description
FROM devicelist AS a, devicegroup AS b
WHERE a.groupID = b.groupID
GROUP BY a.groupID



$query = DB::table('devicelist as a')
  ->join('devicegroup as b', 'a.groupID', '=', 'b.groupID')
  ->select(DB::raw('count(*) as user_count, a.groupID, b.description'))