oracle 在oracle sql字符串中查找逗号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10327697/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
find comma in oracle sql string
提问by Adeel Aslam
I have a column in my oracle db as character and data stored in this is like here
我的 oracle 数据库中有一个列作为字符和存储在此的数据就像这里
30.170527093355002,72.615875338654 and
30.805165,71.82474
Now I want to get the separated by comma whole string. I mean I want to get the part of string before comma and also part after comma separately. Please any one tell me is there any built in function to do this that I can separate my while string by comma regardless of comma position where it exist.I have already tried floor function and substr but all in vain please help me to use any built in function or user defined function to full fill my requirements.
现在我想得到由逗号分隔的整个字符串。我的意思是我想分别获取逗号之前的字符串部分和逗号之后的部分。请任何人告诉我是否有任何内置函数可以做到这一点,我可以用逗号分隔我的 while 字符串,而不管它存在的逗号位置。我已经尝试过 floor 函数和 substr 但都是徒劳的,请帮助我使用任何内置的在函数或用户定义的函数中完全满足我的要求。
回答by Kelly
select
substr( COLNAME, 1, instr( COLNAME, ',') - 1 ) as p_1 ,
substr( COLNAME, instr( COLNAME, ',', - 1 ) + 1 ) as p_2
from YOURTABLE