开发者

MySQL select of everything before @

开发者 https://www.devze.com 2023-03-27 03:04 出处:网络
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?开发者_开发知识库

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消