且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Laravel!=运算符在不起作用的地方

更新时间:2023-11-13 15:47:28

NULL值不等于或不等于其他任何值.

NULL values are not equal or not equal to anything else.

所以column != NULLcolumn = NULL一样总是虚假的

要检查列是否包含NULL值,您需要使用IS NULL运算符.

To check if a column contains NULL value you need to use IS NULL operator.

在使用laravel db查询生成器的情况下,您可以使用

In case of laravel db query generator you could use

->whereNull('video_of_week_expired')

方法.

PS:如果假定video_of_week_expired是类似于标志的列,则***将其设置为NOT NULL并使用0/1值,而不是NULL/1

PS: if video_of_week_expired is assumed to be a flag-alike column, you better make it NOT NULL and use 0/1 values, instead of NULL/1