I want to select out the part of an email address column before @
. So if a row is somebody@somewhere.com
, how do I select somebody
out of each row?开发者_开发知识库
Thanks!
select substring_index('somebody@somewhere.com', '@', 1);
doc -- http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_substring-index
SELECT SUBSTRING_INDEX(email, '@', 1) AS emailname FROM table;
精彩评论