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 .(dot) i have writing some sql but it have fixed length i need the dynamic query to get the sub-string.
select *from registration where email like '%@%';
Sub string Query select email, substr(email,4,10) from registration;
please and one write query for me.
This should do it:
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").
substring_index()
is the best approach:Try using nested SUBSTring_INDEX function. http://www.w3resource.com/mysql/string-functions/mysql-substring_index-function.php