Select all text after specific character

Database
Fan

Select all text after specific character

I want all text AFTER the @ from an email address.  I have the syntax for BEFORE the @ but want everything after the @?

syntax for BEFORE

 

SEL SUBSTRING(col FROM 1 FOR POSITION('@' IN col) - 1)

2 REPLIES
Teradata Employee

Re: Select all text after specific character

SELECT SUBSTRING(col FROM POSITION('@' IN col)+1)

Enthusiast

Re: Select all text after specific character

Another alternative could be 'STRTOK' function.

SELECT STRTOK('TEST@ABC.COM','@',1) will give you the LEFT of @ & SELECT STRTOK('TEST@ABC.COM','@',2) will give you the RIGHT of @.