【发布时间】:2020-10-08 04:04:03
【问题描述】:
我需要 invoice,invoice_details 表中的所有列,但我只想从付款表中获取一列(列名:amount)。我的查询是什么?这是我的控制器。
$all_invoice = DB::table('invoice')
->join('invoice_details', 'invoice.invoice_id', '=', 'invoice_details.invoice_id')
->join('payment', 'invoice.invoice_id', '=', 'payment.invoice_id')
->where('invoice.client_id', 7)
->orderBy('invoice.invoice_id', 'DESC')
->get();
【问题讨论】:
-
然后只使用 select, DB::table('invoice')->select("payment.amount")
-
这能回答你的问题吗? Eloquent get only one column as an array
标签: mysql laravel laravel-blade