Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare Phone Numbers

Status
Not open for further replies.

IFORD

Technical User
Sep 21, 2004
32
US
I have a query that has information from two different table on it importcustomer and tblcustomer I would like to compare the phone numbers This is what I have:

SeLECT IMPORTCUSTOMER.[NAME ID], IMPORTCUSTOMER.RESIDENCEPH, tblCustomer.RESPHONE, IMPORTCUSTOMER!RESIDENCEPH Like tblCustomer!RESPHONE AS RPHONE
FROM tblCustomer INNER JOIN IMPORTCUSTOMER ON tblCustomer.CUSTNO = IMPORTCUSTOMER.[NAME ID]
WHERE ((([IMPORTCUSTOMER]![RESIDENCEPH] Like [tblCustomer]![RESPHONE])=0));

I'm looking for the differents between the residenceph and the resphone but it gives me thing that are not differ to me but i can see how it thinks it is differ like

resphone residenceph
(845)555-1234 845-555-1234

How do I write it that it see these as the same.

Thank you Irene
 
You usually want to get rid of spurious characters like ()- and space before you do the comparison
Code:
SELECT I.[NAME ID], I.RESIDENCEPH, C.RESPHONE

FROM tblCustomer C INNER JOIN IMPORTCUSTOMER I ON C.CUSTNO = I.[NAME ID]

WHERE 
Replace(Replace(Replace(Replace(I.[RESIDENCEPH],"(",""),")",""),"-","")," ","") 
      <>

Replace(Replace(Replace(Replace(C.[RESPHONE],"(",""),")",""),"-","")," ","")
The LIKE keyword reduces to an equals(=) test if you don't use wildcard characters.

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Thank you for you help, when I tryed your code I get a data type mismatch in criteria expression and I can not figure out why Do you have any ideas
 
Could be that you have NULLs in some of your fields. Try
Code:
SELECT I.[NAME ID], I.RESIDENCEPH, C.RESPHONE

FROM tblCustomer C INNER JOIN IMPORTCUSTOMER I ON C.CUSTNO = I.[NAME ID]

WHERE 
Replace(Replace(Replace(Replace([COLOR=red]NZ([/color]I.[RESIDENCEPH][COLOR=red])[/color],"(",""),")",""),"-","")," ","") 
      <>

Replace(Replace(Replace(Replace([COLOR=red]NZ([/color]C.[RESPHONE][COLOR=red])[/color],"(",""),")",""),"-","")," ","")

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top