【问题标题】:Fetching the substring from database and store to the table从数据库中获取子字符串并存储到表中
【发布时间】:2016-01-02 12:02:44
【问题描述】:

如何获取部分电子邮件?例如,我在表用户中有电子邮件 sourabh@winworldsoft sourabh@in.pwc.com 用于列电子邮件,我只需要获取公司名称的一部分并将其存储到列公司的同一个表中我使用了一些正则表达式,但出现了结果在 sourabh@in.pwc.com 之类的某些情况下,并不像我预期的那样。我正在使用子字符串函数我正在使用select

substring_index(substring_index(email, '@', -1), '.', 1)

但这对于第二个 eamil id 来说是错误的。我想通过正则表达式检查是否可能。有人可以帮助我吗?我会非常感激。

【问题讨论】:

  • 两种情况下您的预期输出是什么?
  • 在这两种情况下,例如在第一封电子邮件中我想获得 winworldsoft,而在第二封电子邮件中我只想获得 pwc

标签: php mysql database


【解决方案1】:

我希望这是你需要的:

substring_index(substr(email, 1, (length(email)- length(SUBSTRING_INDEX((email), '.', -1))-1)), '@', -1)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-03
    • 2014-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-20
    • 2014-02-18
    相关资源
    最近更新 更多