Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

query to extract as far as the @ symbol in email addresses

Explorer ,
Oct 07, 2010 Oct 07, 2010

Hello.

I'd like to create a MySQL query to extract everything 'on the left' of the @ symbol in a set of email addresses, plus the @ symbol itself, plus an ellipsis.

In other words, if johndoe@example.com was in the list, I'd like the query to return just this:

johndoe@…

That is, returning just the first part of the email address but omitting the host.

Would anyone like to oblige me by telling me what that query would be?

Thanks in advance for your help.

Hugh

TOPICS
Server side applications
416
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 10, 2010 Oct 10, 2010

hughanagle wrote:

I'd like to create a MySQL query to extract everything 'on the left' of the @ symbol in a set of email addresses, plus the @ symbol itself, plus an ellipsis.

SELECT CONCAT(SUBSTRING_INDEX(email, '@', 1), '...') AS trimmed_email

FROM mytable

Translate
LEGEND ,
Oct 08, 2010 Oct 08, 2010

The MySQL reference document is your friend: http://dev.mysql.com/doc/

Try:

LEFT (MyColumn, LOCATE( '@',MyColumn))

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 10, 2010 Oct 10, 2010

hughanagle wrote:

I'd like to create a MySQL query to extract everything 'on the left' of the @ symbol in a set of email addresses, plus the @ symbol itself, plus an ellipsis.

SELECT CONCAT(SUBSTRING_INDEX(email, '@', 1), '...') AS trimmed_email

FROM mytable

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 10, 2010 Oct 10, 2010
LATEST

Thanks bregent. Thanks David. Your help is much appreciated.

Hugh

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines