我想知道是否有类似可选的 where 查询之类的东西。例如:
从表中选择 *,其中 X 必须 = 2,Y 必须等于 0 或 1?
最佳答案
您可以尝试:
$userId = $request->input('userId');
->where('X', 2)
->where(function($q) use($userId) {
$q->where('Y', $userId)
->orWhere('Y', 1)
})
关于mysql - Laravel 可选 where() 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40321483/