SQL query doesn't work with one record

ITguy1981

Registered User.
Local time
Today, 03:09
Joined
Aug 24, 2011
Messages
137
I currently have a database that looks for record matches between two tables. It is looking for same FirstName, LastName, MidName, and DOB.
Here is the query:
SELECT [Beaver A&D Waiver].LASTNAME, [Beaver A&D Waiver].FIRSTNAME, [Beaver A&D Waiver].MIDNAME, [Beaver A&D Waiver].DOB, [Beaver A&D Waiver].SSN
FROM [Beaver A&D Waiver] INNER JOIN [Updated Table] ON ([Beaver A&D Waiver].MIDNAME=Left([Updated Table].MIDNAME,1)) AND ([Beaver A&D Waiver].FIRSTNAME=[Updated Table].FIRSTNAME) AND ([Beaver A&D Waiver].LASTNAME=[Updated Table].LASTNAME) AND ([Beaver A&D Waiver].DOB=[Updated Table].DOB)
ORDER BY [Beaver A&D Waiver].LASTNAME, [Beaver A&D Waiver].FIRSTNAME, [Beaver A&D Waiver].MIDNAME;

The query cuts the middle name to only match the first letter and so far it has been flawless. All of the sudden I have a record match of exact first, middle, last, and DOB and it's not detecting the match. I changed match on the midname to look for a whole match instead of the first letter and it worked. I need the search of only the first letter on the middle name because the one table typically only has the first letter of the middle name. I can't seem to figure out why all of the sudden that one record is having an issue with just matching the first letter of the middle name. Other matches with the middle name Robert and R seem to still work.

Any help or changes to the query are greatly appreciated. I was wondering if there is a way to search for full middle name and/or first letter of middle name in the query?
 
shouldn't this

([Beaver A&D Waiver].MIDNAME=Left([Updated Table].MIDNAME,1))

be

(left([Beaver A&D Waiver].MIDNAME,1)=Left([Updated Table].MIDNAME,1))
 
OMG. I fixed the problem kinda. Not sure why the midname on the one record wasn't dropping down to the first letter like the others, but I just added another search as OR for the full midname.

([Beaver A&D Waiver].MIDNAME=Left([Updated Table].MIDNAME,1) OR ([Beaver A&D Waiver].MIDNAME=[Updated Table].MIDNAME)
 

Users who are viewing this thread

Back
Top Bottom