Search code examples
sqladvantage-database-server

Select everything to the right of a specific character


Given this data:

Home: (708) 296-2112  

I want everything to the right of the : character.

This is what I have so far, but I'm getting no results:

right(phone1, locate(':', phone1 + ':')-1) phone

If I use left instead of right, I get just "HOME" - just for testing purposes. I know I'm close, but I'm missing something.


Solution

  • You can use SUBSTRING (might be SUBSTR dependent on your version) instead:

    SELECT SUBSTRING(phone1, LOCATE(':', phone1) + 1, LENGTH(phone1))
    FROM yourtable