I want to execute following mysql command in laravel
SELECT stars.*, SUM(points.amount) AS total_points
FROM stars
LEFT JOIN points ON stars.id = points.star_id
GROUP BY stars.id
So I wrote:
\DB::table('stars')
->leftJoin('points', 'stars.id', '=', 'points.star_id')
->select(\DB::raw("stars.*, SUM('points.amount') AS total_points"))
->groupBY('stars.id')
->get();
when I dump and die the result, I see total_points is 0.0. What's Wrong?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2G6dR52
via IFTTT
Aucun commentaire:
Enregistrer un commentaire