I have a SQL statement which - trimmed down for this question - looks like this:
SELECT *
FROM Customers
LEFT JOIN SMS_Blacklist ON Customers.MobileNumber = SMS_Blacklist.Mobile_Number
WHERE SMS_Blacklist.Mobile_Number IS NULL
This works for the most part however the database has no data continuity or consistency and when the data looks like this:
- Customer.MobileNumber = "07123 456789",
- SMS_Blacklist.Mobile_Number = "07123456789"
it returns the record when it shouldn't (because the phone numbers don't match).
My question is, is it possible to perform a string function (i.e. string.replace(" ", "")) in the middle of the SQL statement so it might look something like this (I think probably not):
...
ON (Customers.MobileNumber).replace(" ","") = SMS_Blacklist.Mobile_Number
...
or how could I achieve something like this?
I am creating the SQL statement using new SqlCommand() in C#.