Joining properties using partial lookup

L

Leesha H

Can you join properties of tables using a partial match?
I am trying to link two tables. I want to have
information returned to me if the two fields joining the
tables have a partial match (not just limiting to an exact
match). Is this possible, and if so, how?

Thanks
 
J

John Vinson

Can you join properties of tables using a partial match?
I am trying to link two tables. I want to have
information returned to me if the two fields joining the
tables have a partial match (not just limiting to an exact
match). Is this possible, and if so, how?

Thanks

Sometimes, depending on just what you mean by "a partial match". Could
you cite an example with sample data?
 
L

Leesha H

I have two tables, each has a customer name field, which
is what I want to link the tables with. Using an example,
on one table ("master"), I have a listing of 25000
customer entries with names, address, customer #'s, etc.
On the other table, I have a list of 1000 customer names
whose information I want to match and pull from the other
table. However, the customer name on the master table is
Fleet Boston LLC, where as on the smaller table the
customer name is Fleet. I want to be able to link these
two to pull all of the information (rather than typing
each individual name in the criteria), but I can't
determine if this can be done, as the joining properties
pull information if it is an exact match.
 
J

John Vinson

I have two tables, each has a customer name field, which
is what I want to link the tables with. Using an example,
on one table ("master"), I have a listing of 25000
customer entries with names, address, customer #'s, etc.
On the other table, I have a list of 1000 customer names
whose information I want to match and pull from the other
table. However, the customer name on the master table is
Fleet Boston LLC, where as on the smaller table the
customer name is Fleet. I want to be able to link these
two to pull all of the information (rather than typing
each individual name in the criteria), but I can't
determine if this can be done, as the joining properties
pull information if it is an exact match.

This is one reason that most developers assiduously avoid EVER using
names as linking fields. A Primary Key has three desired attributes:
it's unique, stable, and short. Company names (and even more so,
people's names) fail on all three counts!

Is Fleet Enemas a match to Fleet? How about the hypothetical G. R.
Fleet LLC? What - in terms that a fast-but-excessively-literal
computer can understand - constitutes a "partial match"?

The best you can do, to my knowledge, is to use a LIKE clause in the
join:

SELECT <whatever>
FROM small INNER JOIN large
ON large.CompanyName LIKE small.CompanyName & "*";

This will match "Fleet" with "Fleet Boston LLC", and also with "Fleet
Enemas", but not with "G. R. Fleet LLC".

You could also put a * before the companyname, but that would get many
more false hits and might not work at all, since a leading wildcard
blocks use of indexes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top