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

  • SEARCH
  • Home
  • 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 6609495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:43:29+00:00 2026-05-25T19:43:29+00:00

My current MSSQL table has a phone column which is a varchar. Unfortunately, the

  • 0

My current MSSQL table has a “phone” column which is a varchar. Unfortunately, the phone numbers that are already in the database are not in standard format. For example, 888-888-8888 OR 888/888/8888 OR (888)8888888 OR 8888888888.

I want to get all the rows that are equivalent to 88888888, i.e it should match with 888-888-8888, (888)888888 etc.

I have tried using REPLACE() but there are certain rows where entries have other alphabetic characters like “e”, “ex”, “ext”, etc. So I would like to replace all non-numeric characters.

What would be the best way to get the “matching” rows using MSSQL query?

  • 1 1 Answer
  • 0 Views
  • 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-25T19:43:30+00:00Added an answer on May 25, 2026 at 7:43 pm

    A simple version using MySQL:

    SELECT * FROM `phones` WHERE `phone` LIKE '%8%8%8%8%8%8%8%8%8%8%'
    

    Using PHP:

    // Get all your table rows into $rows using SELECT ..
    foreach ($rows as $row) {
        $row['phone'] = preg_replace('/\D/', '', $row['phone'];
        // Save the row using UPDATE ..
    }
    

    The regular expression \D matches any non-numeric character. See php.net/preg_replace for more information.

    If you just want to find a row that matches “8888888888”, then you could use:

    if (preg_match('/\D*8\D*8\D*8\D*8\D*8\D*8\D*8\D*8\D*8\D*8\D*/', $row['phone'])) {
        ..
    }
    

    Which could simplify/abstract to:

    $match = '8888888888';
    if (preg_match('/' . preg_replace('/(\d)/', '\D*$1', $match) . '\D*/', $row['phone'])) {
        ..
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing a mysql table and i have one column that has current timestamp
We have a sql database at work with a table, employees that has a
I have a database that has a table that has different LIKES that people
Does the MySQL command : FLUSH TABLES; flush every table in the current database,
Current, I've got a stored procedure that has a main goal of doing a
I have a MySQL table which has three columns: Authority | MapID | Time
I have a MySQL table from a third-party application that has millions of rows
I'm backing up MySql -table to worksheet. My current result-set has rows where some
I have a PHP script that inserts data into a mysql database. The table
I have a table which has no primary key and I can't add one

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.