LARLAVELE EQUEPOINT中的‘<;>;’和‘!=’有什么不同?
->where("payed",'<>',2)
这给了我空数组,但当我try 以下命令时:
->where(function ($query){
$query->where('payed','!=',2)
->orWhere('payed',null);
})
它起作用了
->where("payed",'<>',2)
LARLAVELE EQUEPOINT中的‘<;>;’和‘!=’有什么不同?
->where("payed",'<>',2)
这给了我空数组,但当我try 以下命令时:
->where(function ($query){
$query->where('payed','!=',2)
->orWhere('payed',null);
})
它起作用了
->where("payed",'<>',2)
This '<>'
and '!='
is "not equal" in terms of SQL.个
但不同的是结果
在->where("payed",'<>',2)
中,您正在判断'payed'
不等于2的记录.如果是'payed'
,则is null, it will not be returned是因为NULL不与2进行比较.
在第二个查询中,您将判断'payed'
不等于2或'payed'
为空的记录.这意味着it includes the records where 100 is null
因此,如果您希望在第一个查询中包含null
个值,则必须使用
->where('payed', '<>', 2)->orWhereNull('payed')