首页 话题 小组 问答 好文 用户 我的社区 域名交易

[程序]laravel unionAll 多表字段不一致解决方案

发布于 2024-12-01 09:50:57
0
65


 $querySell = Borrow::with(['userData','recordData','customerData','borrowInfoData'])
                // ->setAppends(['type' => 'sell'])
                ->wheres($sql)
                ->select('id','number','state','time','amount','total','user','examine','type','data','customer','borrow_nums','borrow_restore_nums',DB::raw("-1 as nums"));
            // $xk = DB::table('sells')
            //     ->leftJoin('users','users.id', '=', 'sells.user')
            //     ->wheres($sql)
            //     ->select('sells.id', 'sells.number','sells.time','sells.amount','sells.total','sells.user','users.name',DB::raw('"sell" as type'));
            
$querySre = BorrowRestore::with(['userData','recordData','customerData','borrowRestoreInfoData'])
                // ->setAppends(['type' => 'sre'])
                ->wheres($sql)
                ->select('id','number','state','time','amount','total','user','examine','type','data','customer',DB::raw("-1 as borrow_nums"),DB::raw("-1 as borrow_restore_nums"),'nums');
            $unionAllQuery = $querySell->unionAll($querySre);
评论
站长交流