【发布时间】:2020-11-27 12:19:32
【问题描述】:
我正在尝试在不同的表中减去两个整数值,这是我迄今为止尝试过的。
Controller:
$amount = DB::table('shipping_datas')->where('amount')->first();
$payment = DB::table('payments')->where('amount')->first();
$balance = $amount - $payment;
Blade:
{{ $balance }}
提前谢谢你:)
【问题讨论】:
-
虽然您的要求不是很清楚,但我认为您的两个变量($amount 和 $payment)都查询同一个表: DB::table('shipping')->where ('金额');
-
有什么问题?得不到结果?在代码中的 2 个表中相同。您没有在查询后添加
->first()。您无法获得结果。 -
好的,谢谢您的回复,请稍候
-
两者都相同
DB::table('shipping')->where('amount');实际上问题不清楚。请您进一步澄清一下,您要达到的目标是什么? -
->where('amount')->first();但是您的系统如何知道哪一行?可能你错过了->where('amount', 100)或->where('id', 1)