[英]Removing spaces from a string, SQL
I'm trying to write a SQL query that will remove all spaces so that if a string only has spaces the final string is just ''. 我正在尝试编写一个SQL查询来删除所有空格,这样如果一个字符串只有空格,那么最后一个字符串就是''。
I've tried this code but apparently it isn't working for more than one space: 我已经尝试过这段代码,但显然它不适用于多个空间:
regexp_replace(:P14_search_text, '( ){1,}', '')
Being : P14_search_text
the string I want to modify. 存在:
P14_search_text
我想要修改的字符串。
Any help? 有帮助吗?
怎么样:
regexp_replace(:P14_search_text, '[[:space:]]*', '');
试试这个:
Select Replace(:P14_search_text, ' ', '');
Hope this helps you, 希望这能帮到你,
SELECT REGEXP_REPLACE(' Any String ','( ){1,}','') "REGEXP_REPLACE" FROM DUAL;
SELECT REGEXP_REPLACE(' ','( ){1,}','') "REGEXP_REPLACE" FROM DUAL;
the following query works for me in oracle: 以下查询在oracle中适用于我:
select
:tst_val AS INPUT,
regexp_replace(:tst_val, '[[:space:]]*', '') AS MODIFIED
from
dual
if this query does not work for you, would you show us what results you're getting? 如果此查询对您不起作用,您能告诉我们您的结果是什么吗?
I tried the same method as @Don suggested and it works in oracle 10 xe. 我尝试了与@Don建议相同的方法,它适用于oracle 10 xe。
select replace(' lkjds d s adkj ', ' ', '') from dual
result 结果
lkjdsdsadkj
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.