在ORACLE SQL的where子句中使用空字符串修剪

前端之家收集整理的这篇文章主要介绍了在ORACLE SQL的where子句中使用空字符串修剪前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图弄清楚为什么下面的sql语句不会在oracle中返回值do

Select 'do' from dual
where trim('  ') = ''

在哪里

Select 'do' from dual
where trim(' a ')='a'

返回值do.

解决方法

因为trim(”)返回null而不是”

SQLFiddle example

In Oracle 8,there is no such thing as a zero-length string. Any zero-length string,either from a function call or the literal ”,is treated as null.

Source

猜你在找的Oracle相关文章