例
DB::table('foo as f') ->leftJoin( DB::raw(" LATERAL ( SELECT MIN(goods.amount) as min_amount FROM goods WHERE foo.goods_id = goods_id ) as temp_min_amount "), DB::raw('1'), '=', DB::raw('1') ) ->select('f.*', 'temp_min_amount.min_amount ) ->get();
ポイント
- DB::rawを使う
- ON句が不要の場合は、SQL的には
ON 1 = 1
とかON TRUE
とかにしたいのだが、laravel的にはON 1 = 1
一択っぽい。ただし、1=1
するためには、DB::raw('1') = DB::raw('1')としないといけない