Inner Join Uppercased Text Fields

I'm running a query to clean up unsubscribed email addresses. I have a "remove" list and I have the customer list. I'm using an inner join to link the two lists (tables) and then remove the email address from the customer so they don't receive more emails.

How can I handle it if the capitolisation is different from the Remove list to the Customer list?
Is there a way of forcing both lists to upper or lowercase so that I get a match no matter how the email address was entered?

PS: Running Access front end with a few local tables but most via an ODBC link to the SQL server.
LVL 10
slamhoundAsked:
Who is Participating?
 
CutSackConnect With a Mentor Commented:
Hi slamhound,

Can you convert the joined fields to lower case in your query? i.e.:

Select *
from table1 inner join table2
on lcase(table1.email) = lcase(table2.email)

Select *
from table1 inner join table2
on lcase(table1.email) = lcase(table2.email)
 
(above for odbc) or if using a T-SQL Query use below:
 
Select *
from table1 inner join table2
on lower(table1.email) = lower(table2.email)

Open in new window

0
 
slamhoundAuthor Commented:
I'm using an Access query so I tried your LCase example but it's taking ages to run. The customer file (on SQL) is quite large but the unsubscribe list (Access) is quite small.

Is there any way to speed this process up?
0
 
CutSackCommented:
The qurey below might be quicker (although I' not sure if the syntax is valid in access) - the conversion to lower case is already done before the join.

If not , you might need an index on the email field in the SQL table if it is taking a long time.


Select * 
from (select lcase(email) as lemail from sqlcust) as scust
inner join (select lcase(email) as lemail from accesscust) as acust
on scust.lemail = acust.lemail

Open in new window

0
All Courses

From novice to tech pro — start learning today.