![](/img/trans.png)
[英]ValidationError: “column” is not allowed to be empty on null column
[英]Checking if a column is not null or empty
有没有更好的方法来执行以下操作以检查列是否不为空/空?
(v.file_name is not null and v.file_name != ''
and v.file_last_known_location is not null and v.file_last_known_location != '')
我认为这更清楚
COALESCE(v.file_name,'') != '' AND COALESCE(v.file_last_known_location,'') != ''
在某些系统上,这对索引列的性能可能更糟(如@sgeddes所述)。
我要说的是,即使当前查询看起来很笨拙,当在file_name
和file_last_known_location
上建立索引时,它也会执行建议的答案。
在Where
子句中使用function
会限制优化器使用Index
。 所以最好使用原始查询
(v.file_name is not null and v.file_name != ''
and v.file_last_known_location is not null and v.file_last_known_location != '')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.