我找不到让它工作的方法。我必须表格,第一个带有订单,第二个带有跟踪。我想将最新的跟踪行添加到左表行。这是我迄今为止尝试过的(不起作用):
$this->db->select('orders.*, trackings.id AS trackings_id, trackings.order_id AS trackings_order_id, MAX(trackings.status) AS trackings_status, trackings.created_at AS trackings_created_at, trackings.updated_at AS trackings_updated_at, trackings.ip_address AS trackings_ip_address');
$this->db->from('orders');
$this->db->join('trackings', 'orders.id = trackings.order_id', 'left');
$this->db->group_by('trackings.order_id');
$this->db->order_by('orders.created_at', 'DESC');
$query = $this->db->get();
return $query->result();