Fetching The Sub-string From The Database
I have a table with a column which contains strings like below. sourabh@winworldsoft.com monica@winworldsoft.com sachin@winworldsoft.com I need to get the substring from the @ to .
Solution 1:
This should do it:
SELECT REVERSE(SUBSTRING(REVERSE(SUBSTRING_INDEX(email, '@', -1)), LOCATE('.', REVERSE(email))+1));
This will include all dots between @ and the final one (e.g. "someone@a.long.domain.name.com" will result in "a.long.domain.name") as opposed to nested SUBSTRING_INDEX which will only return whats between @ and the first dot (e.g "a").
Post a Comment for "Fetching The Sub-string From The Database"