Laravel加入并合并

时间:2018-06-24 10:21:41

标签: laravel

我有一个数据库查询。现在它已经在工作,但是我正在尝试向该查询添加template<class T> class A { /* ... */ }; template<class T, class U = T> class B { /* ... */ }; template <class ...Types> class C { /* ... */ }; template<template<class> class P> class X { /* ... */ }; X<A> xa; // OK X<B> xb; // OK in C++17 after CWG 150 // Error earlier: not an exact match X<C> xc; // OK in C++17 after CWG 150 // Error earlier: not an exact match 方法,但我没有这样做。我想将两个表与unionAll方法结合起来。

unionAll

1 个答案:

答案 0 :(得分:1)

使用unoinAll()方法,并确保您确实需要全部合并,s/January/01/ s/February/02/ s/March/03/ s/April/04/ s/May/05/ s/June/06/ s/July/07/ s/August/08/ s/September/09/ s/October/10/ s/November/11/ s/December/12/ s/\(.* -\) \([0-9]*\) \([0-9]*\) \([0-9]*\)/\1 \4\3\2/ union之间有区别

union all

或者您可以将这些查询合并为一个查询

$homeCovering = DB::table('bid_requests')
    ->select('bid_requests.*')
    ->leftJoin('bid_home_coverings', 'bid_requests.id', '=', 'bid_home_coverings.bidId')
    ->where('bid_requests.userId', '=', $uid)
    ->where('district', '!=', null);

$bid_requests = DB::table('bid_requests')
    ->select('bid_requests.*')
    ->leftJoin('bid_vehicle_coverings', 'bid_requests.id', '=', 'bid_vehicle_coverings.bidId')
    ->where('bid_requests.userId', $uid)
    ->unionAll($homeCovering)
    ->where('district', '!=', null)
    ->get();

如果您需要不同的出价请求,请添加$bid_requests = DB::table('bid_requests') ->select('bid_requests.*') ->leftJoin('bid_vehicle_coverings', 'bid_requests.id', '=', 'bid_vehicle_coverings.bidId') ->leftJoin('bid_home_coverings', 'bid_requests.id', '=', 'bid_home_coverings.bidId') ->where('bid_requests.userId', $uid) ->where('district', '!=', null) ->get();