0

Currently I am trying to create a "best match" query.

I came across this answer, but the main difference is that I have a table with more columns, and I need to compare 6 strings.

Is there a way to implement the Levenshtein distance algorithm with a query that involves this many comparisons? All the examples I've seen online involve a single comparison sort. Is there a better way of getting the best match in a query involving this many comparisons?

EDIT

So here is the table I am trying to query best match:

CustomerID  CustomerName    CompanyName             CompanyPhone    CompanyEmail        AddressL1  PostalCode
1           terbubbs        terbubbs incorporated   1234567890      terbubbs@gmail.com  5 Main St  06482

This "best match" query is done when a user submits an order request. They will enter data into identical fields and I need to make sure whether this user has submitted a request in the past.

Here are three possible requests:

1. CustomerName CompanyName   CompanyPhone  CompanyEmail        AddressL1  PostalCode
   terrbubbs    terbubbs inc  11234567890   terbubbs@gmail.com  7 Main St  06482

2. CustomerName CompanyName             CompanyPhone    CompanyEmail        AddressL1    PostalCode
   terribble    Terribble Incorporated  1254643789      terribble@gmail.com 12 State St  04422

3. CustomerName CompanyName  CompanyPhone   CompanyEmail    AddressL1  PostalCode
   john doe     JD inc       5468791313     john@gmail.com  12 Main St  06482

Now based on these three requests, I would want Request 1 to be the best match. Honestly, this is probably a terrible example.. My point is that a user might submit an almost identical request besides a few misspellings or grammar mistakes. I want to retrieve the most similar entry in the datatable if possible.

EDIT 2

I'm wondering if it is better to try and concatenate corresponding datatable column values into a formatted string and compare it to a formatted string of the request. Any thoughts?

Community
  • 1
  • 1
terbubbs
  • 1,512
  • 2
  • 25
  • 48

0 Answers0