如果我有两张表(收入和结果),如何获取每日报告?
$stream = file_get_contents('response.txt');
$response = new Response(200, ['Content-Type' => 'application/json'], $stream);
dd($response->getBody());
我想要每天/每天的SUM(total_in)和SUM(total_out)。 如何获得这样的数据,:
structure table
income --> id | date_in | total_in |
outcome --> id | date_out | total_out |
我尝试使用此代码,但它只能从一个表中显示:
======================================================
| Date | Total In | Total Out | Profit(out-in) |
--------------------------------------------------
| 01-01-2017 | 100 | 100 | 0 |
| 02-01-2017 | 100 | 200 | 100 |
| 02-01-2017 | 100 | 300 | 200 |
| ---------- | --- | --- | - |
| 31-01-2017 | 100 | 400 | 300 |
======================================================
如何从两个表中获取价值,仅从1个表(收入)中获取价值,它如何与结果相结合?
答案 0 :(得分:0)
在Income表中创建主键date_id,然后在第二个Outcome表中使用date_id