【发布时间】:2021-02-13 08:38:48
【问题描述】:
我有下面的 Mysql 查询有效。
mysql:
select * from operatories op
left join locations al on op.location = al.location
where op.opname like '%NP%' or op.opname like '%OPEN%'
and al.isOfficeClosed = 0;
这行得通,我得到了我期望的数据,但我试图在 Laravel 查询构建器中编写它,但它没有拾取最后一个 and al.isOfficeClose = 0。有什么你们都可以抓住并看到的吗我做错了吗?
Laravel:
$locs = DB::table('operatories as op')
->leftJoin(DB::raw('locations al'), function($join) {
$join->on('op.Location', '=', 'al.location');
})
->Where('op.opname','LIKE','%NP%')
->orWhere('op.opname','LIKE','%OPEN%')
->where('al.isOfficeClosed', '=','0');
【问题讨论】:
-
op.Location上的大写字母可能会导致连接失败? -
@porloscerrosΨ 不,我试过了。
标签: php laravel eloquent laravel-query-builder