Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a MS Access(2007) table.
A column (called BD_Name) in the table contains a value =
"All - In - One Driving Academy".

I am trying to select that record with the value =
"All-In-One Driving Academy" ie SupplierName.

Note the spaces (or lack thereof) between the "-"'s.

I am trying to merge Suppliers and their Banking details from tables that were never related and populated by different people each with their own sense of what the supplier name should be.

Is there any way I can find that record?

The SQL statement is being issued by a VB.net (4.0) program.

Your advice and assistance, as always, is much appreciated.

What I have tried:

SQL
Ssql = "SELECT BD_Name, BD_AcNo, BD_BranchCode, BD_Bank FROM Supplier_Pastel_Bank_Details WHERE LCASE([Supplier_Pastel_Bank_Details.BD_Name]) LIKE LCASE('%" & SupplierName & "%')"
Posted
Updated 8-Mar-17 0:00am
v2

You can use REPLACE to remove all spaces from a string (untested):
SQL
WHERE LCASE(REPLACE([Supplier_Pastel_Bank_Details.BD_Name], ' ', '') LIKE LCASE(REPLACE('%" & SupplierName & "%'), ' ', '')"

But I suggest to check the results manually to avoid false positives.

In your case it might be also necessary to ignore trailing dots like with "Company Inc." and Company Inc".
 
Share this answer
 
Comments
Darrell de Wet 8-Mar-17 6:42am    
Now that's a good idea. I did not know that I could use .Replace in my Select statement.
Thank you very much.
 
Share this answer
 
Comments
Darrell de Wet 8-Mar-17 6:45am    
Thanks, Richard, for the quick response. I will take a good hard look that these.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900