将此原始查询转换为Laravel查询生成器我遇到了一些问题:
SELECT
(x.ans_277 + x.ans_278 + x.ans_279 + x.ans_280) as jml, `a`.*
FROM
`rawdata` AS `a`
LEFT JOIN `answer` AS `x` ON `x`.`mhs` = `a`.`id`
WHERE
`jalur` = 1
AND `is_lest` = 'Y'
AND `x`.`ans_173` NOT IN (8,10)
AND `x`.`ans_182` NOT IN (17,11)
AND (x.ans_277 + x.ans_278 + x.ans_279 + x.ans_280) < 1000001
ORDER BY
`final_time` ASC
我一直在尝试使用它:
$query->where('(x.ans_277 + x.ans_278 + x.ans_279 + x.ans_280)','<',1000001);
但它不起作用。
答案 0 :(得分:2)
您可以使用whereRaw()
:
$query->whereRaw('(x.ans_277 + x.ans_278 + x.ans_279 + x.ans_280) < 1000001');