Reputation: 1
I have mail address and i want to save the domain name.How to fetch.
Upvotes: 0
Views: 1941
Reputation: 3149
Have you tried the following:
select
substring_index(ColName, '@', -1)
from table
Upvotes: 2
Reputation: 1270401
In MySQL, you would use substring_index()
. To get the string after the last (or only) '@'
, you would use:
select substring_index(str, '@', -1)
from t;
In SQL Server, one method would look like:
select substring(col, charindex('@', col + '@') + 1, len(col))
from t;
Note that if there is no '@'
, then this returns an empty string.
Upvotes: 1