简体   繁体   English

如何从MYSQL中删除部分单词

[英]how to remove part of words from MYSQL

select ename, email, +showing only the site from email(ex. if email is asd.gmail.com only 'gmail') from emp77 选择ename,email,+仅显示来自emp77的电子邮件中的网站(例如,如果电子邮件为asd.gmail.com,则仅显示“ gmail”)

so basically I want to show ename, email, and the site from email 所以基本上我想显示电子邮件中的名字,电子邮件和网站

You can use combination of substr , instr and substring_index : 您可以结合使用substrinstrsubstring_index

select ename,
    email,
    substring_index(
        substr(
            email, instr(email, '@') + 1
        ), '.', 1
    ) as email_domain
from emp77

Or using just substring_index twice, as suggested by @spencer7593 in the comments below: 或仅使用substring_index两次,如@ spencer7593在以下注释中所建议:

select ename,
    email,
    substring_index(
        substring_index(email, '@', - 1)
        , '.', 1
    ) as email_domain
from emp77

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM