gpt4 book ai didi

php - Laravel 5.1 嵌套复杂查询

转载 作者:行者123 更新时间:2023-11-29 19:05:20 25 4
gpt4 key购买 nike

我试图在几个小时内进行此查询,但我无法使用 laravel 语法进行此查询

\DB::select(\DB::raw(
"
SELECT * FROM products AS P WHERE (`d` = $d)
AND (`mis` BETWEEN $min_c AND $max_c)
AND (`e` BETWEEN $e_min AND $e_max)
AND p1 IN
(
SELECT p1
FROM autos AS A
WHERE (`ma` = $strma)
AND (`d` = $d )
AND (`mis` BETWEEN $min_c AND $max_c)
AND (`e` BETWEEN $e_min AND $e_max)
AND (`p1` = P.p1 )
AND (`p2` = P.p2 )
)
AND p2 IN
(
SELECT p2
FROM autos AS A
WHERE (`ma` = $strma)
AND (`d` = $d )
AND (`mis` BETWEEN $min_c AND $max_c)
AND (`e` BETWEEN $e_min AND $e_max)
AND (`p1` = P.p1 )
AND (`p2` = P.p2 )
)
"
));

我想我必须使用两个函数,例如

->whereIn(array('p1','p2'),
function($query){

...
}
function($query2){
...
}
)

但是这不起作用我可以用 Laravel 语法向数据库询问什么方式?

最佳答案

我通过 2 个函数解决了这个问题。

->whereIn('p1',function($query) use (...
->whereIn('p2',function($query2) use (...

关于php - Laravel 5.1 嵌套复杂查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43558173/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com