替换空格,制表符和回车符 [英] Replace spaces, tabs and carriage returns
问题描述
我正在与Oracle 11g的SQL开发人员一起工作.我有一个查询,看起来与此类似;
I am working with SQL developer with Oracle 11g. I have a query that looks something along the lines of this;
SELECT [column], [column], [column],...... rs.notes
FROM [table], [table], [table]............ return_sku rs
WHERE [conditions] AND [conditions] AND [conditions]
在return_sku
列中有制表符,空格和换行符(我相信这是回车符吗?)我需要在运行查询时使所有这些空格,回车符和制表符消失.
In the return_sku
column there are tabs, spaces, and newlines (I believe this is a carriage return?) I need to make all of these spaces, carriage returns and tabs disappear when I run my query.
我对SQL还是很陌生,但是发现的最受欢迎的搜索结果是REPLACE函数.我完全不知道如何使用它,因为我已经尝试了许多不同的方法,但是都没有结果.我已经尝试了以下方法;
I am fairly new to SQL, but the most popular search result I found is the REPLACE function. I have absolutely no idea how to use this, as I've tried this in many different ways with no result. I've tried the following;
SELECT [column], [column], [column],...... REPLACE(rs.notes, Char(10), '')
FROM [table], [table], [table]............ return_sku rs
WHERE [conditions] AND [conditions] AND [conditions]
这给出了错误信息:
ORA-00904: "RS"."NOTES": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 3 Column: 531
如何正确使用此功能?
推荐答案
在Oracle中,如果您只想删除一个字符,则可以省略replace调用的第三个参数,并且字符代码的函数是chr(),而不是char ().
In Oracle if you just want to remove a character you can omit the third argument of the replace call and the function for character codes is chr(), not char().
所以您的行将是SELECT ... replace(rs.notes,chr(10)) ...
这篇关于替换空格,制表符和回车符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!