SQL查询以删除逗号的最后,没有字符以外的字符
我创建了一个查询来从表IRC_Table中获取输出,
Requistion_number Name
12 John Mayer, Andrew,
11 Swastak,
如果名称中的值最终具有逗号,那么它应该删除它 -
Requistion_number Name
12 John Mayer, Andrew
11 Swastak
哪个函数可以帮助我实现这一目标?
I have created a query to get the output like from table IRC_TABLE-
Requistion_number Name
12 John Mayer, Andrew,
11 Swastak,
I want if the values in Name has comma at the end and nothing beyond then it should be removed-
Requistion_number Name
12 John Mayer, Andrew
11 Swastak
Which function will help me achieve this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单,可能是最具性能的方法是使用
trim
:您还可以使用
regexp_replace
在这里:如果替换逻辑为不仅仅是剥离某个最终角色,还要复杂。
The easiest and probably most performant way to do this would be to use
TRIM
:You could use also
REGEXP_REPLACE
here:The regex option would be of more value if the replacement logic were more complex than just stripping off a certain final character.
还有另一个选项(除了蒂姆已经说过的内容外)是
rtrim
( right-trim )函数。当我们搜索各种选项时,即使
substr
case
表达式可能会这样做(但是,嘿,您肯定不想使用它):Yet another option (apart from what Tim already said) is the
rtrim
(right-trim) function.When we're searching for various options, even
substr
withcase
expression might do (but hey, you surely will not want to use it):