我使用交叉连接得到两个表的结果。但是当我试图在视图中显示它时,我会得到这个错误。
调用数组上的成员函数crossJoin()
那么,如何将其安排在HTML表中呢?看上去像下面。
barcode | desc | qty | branch1 | branch2 | branch3 | branch4
------------------------------------------------------------
123456 | lenovo| 100 | null | null | null | null
252666 | hp | 100 | null | null | null | null
895566 | acer | 70 | null | null | null | null
968411 | apple | 800 | null | null | null | null 这是我的密码
$receiving = DB::select('select * from branch')
->crossJoin('allocation_stocks')->get();
return view('operation.home', ['data' => $receiving]);表allocation_stocks
barcode | desc | qty
----------------------
123456 | lenovo| 100
252666 | hp | 100
895566 | acer | 70
968411 | apple | 800 表支
brach_name|
-----------
branch1
branch2
branch3
branch4 发布于 2019-09-27 11:08:13
尝试这个查询。它应该能工作
$receiving = DB::table('branch')
->crossJoin('allocation_stocks')
->get();
return view('operation.home', ['data' => $receiving]);发布于 2019-09-27 11:13:15
要执行“交叉连接”,请使用crossJoin方法,其中包含要交叉连接的表的名称。
交叉连接在第一个表和连接表之间生成一个笛卡儿积:
$receiving = DB::table('branch')
->crossJoin('allocation_stocks')
->get();另请参阅:
发布于 2019-09-27 11:56:26
You can see the query builder in laravel here.$result = DB::table('branch')
->crossJoin('allocation_stocks')
->get();
return view('operation.home', ['data' => $result]);https://stackoverflow.com/questions/58133224
复制相似问题