[英]How to do this query with Laravel query builder
I'm trying to run this query in Laravel, and would like to do it with the query builder, so I can use the paginate() method. 我正在尝试在Laravel中运行此查询,并希望通过查询生成器来执行此操作,因此可以使用paginate()方法。 But I can't seem to figure out how to get this subquery going.
但是我似乎无法弄清楚如何使该子查询继续进行。
The raw query is: 原始查询为:
SELECT *
FROM (
SELECT *
FROM `order_history`
WHERE `customer_id` = '05033'
AND `part_number` LIKE 'M%'
ORDER BY `shippingdate` DESC) history
GROUP BY `part_number`
Thanks in advance! 提前致谢!
DB::table(order_history)->where(function($query)
{
$query->where('customer_id','=','05033')
->where('part_number','like','$m');
})
->group('part_number')
->paginate(10)
->get();
should be correctish 应该正确
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.