INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Comparing Name fields in table

Comparing Name fields in table

(OP)
Hi,

I have two name columns in my table, NAME1 & NAME2 that I want to compare to see if they match. Only problem is that the order of the first, last, middle name can be either same or different between the two fields.

For example
NAME1 = JAY JOHN SMITH
NAME2 = JOHN SMITH JAY or SMITH JOHN JAY

Is there a way to somehow reorder these fields and then compare using SQL?

Thanks a lot!

RE: Comparing Name fields in table

one approach for this is

1 -replace all possible symbol characters with a space
ID=1, name= "john o'dowd" becomes ID=1, name = "john o dowd"
2 - split individual words into single rows - flag duplicates where needed
ID=1, name = "john o dowd" becomes
ID=1, split = 1, name = "john"
ID=1, split = 2, name = "o"
ID=1, split = 3, name = "dowd"

step above becomes the basis for further validation
validation 1
1 - order all split alphabetically
2 - concatenate all splits

once strings are concatenated you can compare them directly, if they don't match you can then also use similarity functions (http://psoug.org/reference/utl_match.html) and those with high enough (.96 or more normally) may be the same.

Validation 2
Those that do not match validation 1
remove duplicates if any - perform validation 1 again

validation 3
Those that do not match validation 2
some cases may not match due to a letter on the middle of one of the names that does not give a exact match, neither gives a high enough score on similarity.
concatenate again all strings, ignoring strings with 1 char only. repeat validation 1


Other things to do - replace all know variations of names like "o'connor", 'o'donahue' with the version without the "'" before doing the replacement mentioned in point 1.
replace zeros with letter O and others the same eventually if you wish to dig deeper


this way if one name is "o'connor" in one field, and "oconnor" in the other they will match. - and you can still flag them as having a difference for users to verify which version of the name is the correct one.

All steps mentioned above will require you to search the net for ways of splitting strings and converting individual splits into rows, and converting rows into a single column with the concatenation of same rows.
words like PIVOT, UNPIVOT, "for xlmpath" will help you on your search

Regards

Frederico Fonseca
SysSoft Integrated Ltd
www.syssoft-int.com

FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?

RE: Comparing Name fields in table

(OP)
Thank you so much for the guidance. Very helpful.

RE: Comparing Name fields in table

There is also sound like codes like soundex or metaphone

Bill
Lead Application Developer
New York State, USA

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close