【发布时间】:2021-10-03 04:04:21
【问题描述】:
我有 2 张桌子 booking_orders(id) 和 booking_order_status_history(id, order_id,status, created_at)
其中booking_order_status_history.order_id = booking_orders.id 可能有不止一行具有相同的 order_id 但我需要获取最新的行。我正在使用 laravel 雄辩的查询
BookingOrders::select("booking_orders.*", "booking_order_status_history.status as status")
->join('booking_order_status_history', 'booking_order_status_history.order_id', '=', 'booking_orders.id'))
->get()
这是从 booking_order_status_history 的保存匹配行中加载所有行。
如何仅获取最后插入的 status 行。谢谢
【问题讨论】: