本文主要是介绍mysql与oracle在使用trim()函数上的区别,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
oracle中测试结果如下:
SQL> select 1 from dual where (trim(' ') is null);
1
----------
1
SQL> select 1 from dual where (trim(' ') = '');
1
----------
mysql中测试结果如下:
mysql> select (trim(' ') = null) , (trim(' ') = '');
+--------------------+------------------+
| (trim(' ') = null) | (trim(' ') = '') |
+--------------------+------------------+
| NULL | 1 |
+--------------------+------------------+
使用通用写法:length(trim('')) > 0 但是也有点坑
mysql> select (length(trim('')) > 0);
+------------------------+
| (length(trim('')) > 0) |
+------------------------+
| 0 |
+------------------------+
SQL> select 1 from dual where (length(trim('')) = 0);
1
----------
SQL> select 1 from dual where (length(trim('ewrewr')) > 0);
1
----------
1
这篇关于mysql与oracle在使用trim()函数上的区别的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!