Laravel 9使用和 /或组合失败
我想写下以下查询,但不会产生我想要的结果。
SELECT * FROM TABLE1 WHERE COLUMN1 = 'DATA' AND ( COLUMN2 LIKE 'K%' OR COLUMN3 LIKE 'K%' OR COLUMN4 = '[email protected]')
我希望上述查询在Laravel 9中雄辩,我已经写下了下面的书,但仍未产生相同的结果。
DB::table('table1')->where(function ($query) use ($request) {
$query->where('column2', 'LIKE', $request -> data)
-> orWhere('column3', 'LIKE', $request -> data )
-> orWhere('column4', '=', $request -> data ) ;
})->get();
提前致谢。
I want to write below queries but it doesn't produce the result that I want.
SELECT * FROM TABLE1 WHERE COLUMN1 = 'DATA' AND ( COLUMN2 LIKE 'K%' OR COLUMN3 LIKE 'K%' OR COLUMN4 = '[email protected]')
I want above queries eloquent in Laravel 9, I have written as below but still doesn't produce the same result.
DB::table('table1')->where(function ($query) use ($request) {
$query->where('column2', 'LIKE', $request -> data)
-> orWhere('column3', 'LIKE', $request -> data )
-> orWhere('column4', '=', $request -> data ) ;
})->get();
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您缺少第一个关于
column1
不是吗?当前,它会产生:
更新您的代码以包括第一个
其中
:现在,它应该按预期工作(至少将产生您期望的查询)。
You are missing the first
where
aboutCOLUMN1
isn't?Currently, it produces:
Update your code to include the first
where
:And now, it should work as expected (at least, it will produce the query you are expecting).