In Microsoft Access, I have a query uniSelectedContacts and table possibles.
Let’s say in possibles I have this:
Smith,John
Dough,John B
Ward,Jane Karon
Eggert,Samantha R
In uniSelectedContacts I have this:
Smith,John A 1552 1st Ave
Dough,John 1111 2st Ave
Ward,Jane K 2222 3st Ave
Eggert,Samantha Rachel 3333 1st Ave
I want to find where first and last name are identifiable. However, due to variation in middle initial, if there’s no middle initial in possibles, then I want to account for all instances of the first and last name from uniSelectedContacts using INNER JOIN. If possibles has a middle initial(name), regardless of its middle initial or name, I want to account for the record(s) where first and last name of uniSelectedContacts and possibles are identical to each other and also where the first letter of middle initial(name) of uniSelectedContacts matches the first letter of middle initial(name) of possibles. So in the above example, this should be returned:
Smith,John 1552 1st Ave
Dough,John B 1111 2st Ave
Ward,Jane Karon 2222 3st Ave
Eggert,Samantha R 3333 1st Ave
The query below is fast and I want to preserve the speed, but
it will skip all the above records (due to differences in middle initial(name):
SELECT possibles.fullname,
uniSelectedContacts.addresses,
uniSelectedContacts.cities,
uniSelectedContacts.us_states_and_canada,
uniSelectedContacts.zip_codes INTO PrepareForDuplicateCheck
FROM uniSelectedContacts INNER JOIN possibles ON uniSelectedContacts.TheName = possibles.fullname;
To try to address the issue above, I have this:
SELECT possibles.fullname,
uniSelectedContacts.addresses,
uniSelectedContacts.cities,
uniSelectedContacts.us_states_and_canada,
uniSelectedContacts.zip_codes,
possibles.[firstname] AS Expr1,
possibles.[lastname] AS Expr2 INTO PrepareForDuplicateCheck
FROM uniSelectedContacts INNER JOIN possibles ON uniSelectedContacts.TheName = possibles.fullname
WHERE (((possibles.firstname)=Left([fullname],InStr([fullname],",")-1))
AND ((possibles.lastname)=Mid([fullname],InStrRev([fullname],",")+1)));
The above gives “Enter Parameter Value possibles.firstname” message. But I’m also not sure if the underlying logic of the query will deliver the results I am expecting.
Thanks for response.
It is a little difficult to tell the fields (columns) from the posted samples, but I am assuming that both tables have a full name in the format surnameforename.
I am not suggesting that this will be fast, but try it.
Another possibility: