SQLTeam.com | Weblogs | Forums

Inner Join Like statement issue


#1

Hi,

I have a query to join two table based on phone number.

SELECT A.* FROM TABLE_A A
INNER JOIN
TABLE_B B
ON A.PhoneNumber LIKE '%' + B.PhoneNo + '%'

Eg. I have phone number +6599981234 at Table_A and 99981234 in Table_B.
How can I write LIKE statement?


#2

yes. Your query is fine


#3

First, how do you decide which part of the phone number you want to match? Is it the rightmost digits? How many digits? Do you ever have to ignore extension "suffixes" (e,g, (999) 555-1000 x1234)? Is either phone number supposed to be the base number without international prefixes?

This will get you a little closer but until we decide on the answers to the above questions, its just a guess...(and likely a poor one)ON A.PhoneNumber LIKE '%' + B.PhoneNo + '%' OR B.PhoneNumber LIKE '%' + A.PhoneNo + '%'