I have two tables that I need to compare and update values in one table if keywords appear in another reference table.
A is a data table that contains a list of individuals with separate fields for a last and first name.
B is another reference table that contains a defined list of individuals with last and first names.
I’m writing an update query in Access to check the individuals in table A to see if they are listed in table B and update a field in A to indicate whether or not they are listed in table B. I’m using the criteria that if the last and first name are the same in both tables, then it is sufficient to be a match. The problem is that names fields table A may contain additional information (such as titles or credentials) that is not in the reference table B, which only lists first and last name. I do not have control over the data in table A, but need to make a join based on like criteria, as best as possible.
I’m not sure how to express the following in SQL. I’m hoping the following pseudo-code, explains what I’m trying to accomplish:
UPDATE A
SET A.[isinB]=true
WHERE
A.[lastname] contains B.[lastname]
and
A.[firstname] contains B.[firstname]
Example:
A.[lastname] = SMITH MD PHD
A.[firstname] = JOHN M
B.[lastname] = SMITH
B.[firstname] = JOHN
In this example, I want this to be considered a match, and A.[isinB] set to true.
In Access you can do a Wildcard compare:
The bookend ““‘s wildcards instruct Access to find the string anywhere within the field that “Like” references, ex. “JOHN” is within “JOHN M” will return true. You may want to consider just specifying the first ““, depending on your data.