$query = new TableA;
$query = $query->join('tableB', 'tableA.b_id', '=', 'tableB.id');
$query = $query->where('tableB.something', '=', '1');
$query = $query->where('tableA.something_else', '=', '2');
它产生:
WHERE something=1 AND something_else=2 AND .. AND....
但现在 - 我需要这个:
WHERE something=1 AND something_else=2 AND (city=city1 OR city=city2 OR city=city3) AND (country=country1 OR country=country2)
有什么想法吗?
答案 0 :(得分:2)
利用Advanced Wheres。对于你的例子,它是这样的:
->where(function ($query) {
$query->where('city', '=', city1)
->orWhere('city', '=', city2)
->orWhere('city', '=', city3);
})->where(function ($query) {
$query->where('country', '=', country1)
->orWhere('country', '=', country2);
});
答案 1 :(得分:0)
快速方法。阅读原始表达式: