Hello I wonder if anyone could help with a sort of reverse lookup query where I am starting with a complete string and need to find a row containing a sub string of it in another table.
The first table contains 4 fields from a monthly bank statement (tblBankStatement):
Date, Transaction Type, Amount, Details
The second is a table of customers (tblCustomers) containing
CustID, FirstName, Surname, PartialBankDetails
I wish to write an SQL statement that will return the CustID of all Customers whose details appear on a bank statement.
The problem is details for some customers vary between statements. So for instance June statement for Anderson may show as “ANDERSON PE&JD” but the July statement might show as just “ANDERSON PE” whilst August could be “ANDERSON PE AND JD. So I store the partial details that I know will not change in tblCustomers (eg. PartialBankDetails contains “ANDERSON PE”).
The only way I can think of to do this would be to run a query from VB in a loop and pass in the abbreviated BankDetails for each individual customer in tblCustomer so that when it got to Anderson it would search on ANDERSON * or use InStr() function but I would much rather do this with SQL without VB if possible.
Many thanks in anticipation
The first table contains 4 fields from a monthly bank statement (tblBankStatement):
Date, Transaction Type, Amount, Details
The second is a table of customers (tblCustomers) containing
CustID, FirstName, Surname, PartialBankDetails
I wish to write an SQL statement that will return the CustID of all Customers whose details appear on a bank statement.
The problem is details for some customers vary between statements. So for instance June statement for Anderson may show as “ANDERSON PE&JD” but the July statement might show as just “ANDERSON PE” whilst August could be “ANDERSON PE AND JD. So I store the partial details that I know will not change in tblCustomers (eg. PartialBankDetails contains “ANDERSON PE”).
The only way I can think of to do this would be to run a query from VB in a loop and pass in the abbreviated BankDetails for each individual customer in tblCustomer so that when it got to Anderson it would search on ANDERSON * or use InStr() function but I would much rather do this with SQL without VB if possible.
Many thanks in anticipation