Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 275207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:43:41+00:00 2026-05-12T00:43:41+00:00

I have a table containing data about some users. Many of them use our

  • 0

I have a table containing data about some users.

Many of them use our in house email system at OLDHOST.com. We have updated to a newer system at NEWHOST.com. All the users usernames are the same, so if you had dave@OLDHOST.com, you are now dave@NEWHOST.com

Is there a better way to change all the email fields in the users table without selecting all the rows in say PHP, then checking if the email has OLDHOST in it, then replacing the string to NEWHOST?

Is there a baked in awesome SQL statement to help with this?


Example of some of the table (simplified)

id | firstname | surname | email
------------------------------------------------
1  | dave      | smith   | a21dsmith@OLDHOST.com
2  | barry     | jones   | a21bjones@OLDHOST.com

etc.

All that needs to be changed is any emails that contain OLDHOST (Not all do) to NEWHOST.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T00:43:41+00:00Added an answer on May 12, 2026 at 12:43 am

    You’ll need to replace the relevant part of each string within an update statement, grabbing the hostname substring after the @ with a REPLACE, and replacing it.

    UPDATE table SET email=REPLACE(email,'OLDHOST.com', 'newhost.com');
    

    Note: REPLACE() is case-sensitive, so you can use LOWER(email) inside the REPLACE function if you need to catch all case possibilities, as below:

    UPDATE table SET email=REPLACE(LOWER(email),'oldhost.com', 'newhost.com');
    

    This will also convert all your email addresses to lowercase, so be aware of that 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following MySql table containing my raw event data (about 1.5 million
Let's say I have a table containing following data: | id | t0 |
I have data table containing one column as FilePath. FilePath D:\New folder\link.txt D:\New folder\SharepointMigration(Work
Ok I have a data table containing duplicate Reciept numbers and a transaction value
I have a db table containing a column display_order . The data looks like
I have a number of tables containing some basic (business related) mapping data. What's
I have a table containing hierarchical data. There are currently ~8 levels in this
If I have an online database containing data about people (name, age, country etc),
I have data containing about 30 000 records. And I need to insert this
Ok, so I have a table containing information about jobs. The goal is that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.