Skip to content
Advertisement

Select where field1 or field2 or field3 is equal to a phone number

I am looking at a table with phone1, phone2 and mobile. However the phone strings are not formatted properly.

The phone numbers are basically free text like this:

Is it possible to write a SQL query to find if one of the fields phone1, phone2 or mobile is +19123123123 but it needs to be able to match any one of those free text examples? Thanks

So in the above example, it should return all 5 records be those free text match that phone number and is in one of the 3 fields.

Advertisement

Answer

Assuming the only numbers and + in the column are in the phone number, you can use:

This removes everything that is not a + or digit.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement