Rahul Vp Rahul Vp - 6 months ago 29
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'))