我有一个像
这样的查询SELECT a.id, a.code, b.id as bid FROM a LEFT JOIN b ON a.code BETWEEN b.start AND b.end
现在如何将此转换为laravel eloquent查询?
我尝试了什么?
A::leftJoin('b', function($j){
$j->on() //here I face complexity. How I implement it
})
答案 0 :(得分:0)
这对我有用
A::leftJoin('b', 'a.code', 'BETWEEN', DB::raw("a.code BETWEEN b.start AND b.end"))->get();