How do I get a substring from this example value:
john.abc_1234
I want it to return john.abc
.So basically we need to remove all the information after _
.
More examples: 1234_abc
How do I get a substring from this example value:
john.abc_1234
I want it to return john.abc
.So basically we need to remove all the information after _
.
More examples: 1234_abc
You can use this monstrosity, when you're not sure if all your values contain the character you want to cut off your string at.
You can use
SUBSTR
andINSTR
:Update
Additionally, if you are running from Oracle 10g on, you could take the Regex path, which would more powerfully handle exceptions.
Here are some links on how to do it in Oracle:
You can use via a simple combination of
substr(..)
andinstr(...)
to find the string which is free fromunderscore
special charecter. Also in order to only select_
containing strings you can make use of additionalwhere
clause as belowThis guy figured it out! http://programcsharp.com/blog/post/strip-non-numeric-characters-from-a-string-in-sql-server