假设我有一个查询
group by m2m_order_flights.customer_id
having max(m2m_order_flights.flight_id=`go_f`.`id`)=1
and max(m2m_order_flights.flight_id=`back_f`.`id`)=1
很明显,该查询上的count()
方法无法正常工作
select count(*) as aggregate from ...
我想要类似
select count(*) from (<my_query>) as t
其中<my_query>
是使用group by
和having
进行的查询。
如何使用\Illuminate\Database\Eloquent\Builder
实现此目标?
谢谢。