SQL Query Failing to Parse some Numbers for CRM Integration

Status
Not open for further replies.

TaylorStevens23

SOHO User
Joined
Jul 27, 2020
Messages
51
Reaction score
9
I am having an issue parsing some of the phone data from our database using the mySQL CRM Integration. The data comes in different forms. Our workphonenumber is formatted like ["(XXX) XXX-XXXX"]. While our homephone numbers in the db are formatted like (XXX) XXX-XXXX.

When I run the following SQL Lookup Statement "SELECT `index` as contactid, firstname as firstname, lastname as lastname, workemail as email, workphonenumber as phonebusiness, homephone as phonemobile, homephone as faxbusiness FROM database WHERE REPLACE(REPLACE(REPLACE(REPLACE(workphonenumber, '(', ''), ')', ''), '-', ''), ' ', '') LIKE '%[Number]%' or REPLACE(REPLACE(REPLACE(REPLACE(homephone, '(', ''), ')', ''), '-', ''), ' ', '') LIKE '%[Number]%'or homephone LIKE '%[Number]%'" I can successfully locate the "contact" from our database for homephone
1699365555760.png

But if I try to locate a number listed in workphonenumber field of the db it seems to find the person but fails to recognize it as a "contact".
1699303877796.png

My initial thought is that the query is failing to parse out the characters ",[, and ]. So I tried to expand my replace string to include the removal of those charcters with the following string WHERE REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(workphonenumber, '"', ''), ']', ''), '[', ''), '(', ''), ')', ''), '-', ''), ' ', '') LIKE '%[Number]%' but that seems to break my query.
1699303923342.png
Do you see any issues with the SQL query/replacement string? Or do you have any thoughts on what I could do differently with the query?
 
Status
Not open for further replies.

Forum statistics

Threads
112,320
Messages
591,878
Members
165,466
Latest member
EMMEPICASA