0
是否有更好的方法来执行以下操作来检查列是否为空/空?检查列是否为空或空
(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 != '')
是否有更好的方法来执行以下操作来检查列是否为空/空?检查列是否为空或空
(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
时。
的function
在Where
子句使用将使用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 != '')
length(trim(filename))> 0也许? – bassxzero
如果您的字段索引正确,我认为您的发布解决方案将超越使用诸如“coalesce”之类的函数,否定索引。 – sgeddes