Jun 13, 2021
0
Level 1
How to make eloquent query with 2 table and two from
Hello everyone, I have no idea, how do this query with eloquent for get object.
SELECT field1, field3, total
FROM (SELECT field1, field3, sum(field2) AS total
FROM sales
GROUP BY field1, field2
) subtable
GROUP BY field1;
I mean how can I do "subtable" table after join two tables then do group by, min and group_concat and etc ... with this result.
In this one query I do "virtual" table "subtable" then do select with some rules for this table.
How can do this way through eloquent?
P.S. Maybe it help for anyone
$query1 = DB::table(DB::raw('(' . $query1->toSql() . ') as tab1'))
looking for in google - "subquery"
Please or to participate in this conversation.