我有两列:average_min
和average_max
。
如果average_min=2000
和average_max=7000
,我需要查找interval
介于2000-7000之间的记录:
$q->whereAverage_minAndAverage_max($data['average_min'], $data['average_max']);
whereFooAndBar
不合适。
答案 0 :(得分:0)
它可能不是一个完整的代码,但问题已解决:)
if($data['average_min']){
$q->where('average_min','<=',$data['average_min']);
$q->where('average_max','>',$data['average_min']);
}
if($data['average_max']){
$q->where('average_min','<=',$data['average_max']);
$q->where('average_max','>=',$data['average_max']);
}