您好我想知道如何从联合表中获取特定值。
这是我的代码
$bank_detail = $this->db->table('sys_bank_details')->where('bank_name', $bank)->first();
$bank_detail_arr = array(
'account_type' => $bank_detail->account_type,
'bank_name' => $bank_detail->bank_name,
'account_name' => $bank_detail->account_name,
'account_number' => $bank_detail->account_number,
);
在上面的代码中,我可以获得特定的数据,因为它只有一个表
但如果我加入桌子怎么办呢?这是我的代码
// Total sale and Transaction Made
$total_sales = $this->db->table('order_payment')
->select(DB::raw('*, sum(order_payment.amount) as total_amount, order_header.*, count(order_header.order_type_id) as total_transaction'))
->leftjoin('order_header', 'order_header.order_id', '=', 'order_payment.order_id')
->where(DB::raw('Date(reference_date)'), $sales_date)
->where('order_header.order_type_id', '2')
->where('order_header.store_id', $manager->store_id)
->get();