Thursday, March 29, 2012

Alternate names

I need to implement support for alternate names on the database Im working on.
When a user looks up: Antony Bigglesworth the query would return both: Antony Bigglesworth as well as Tony Bigglesworth, would both exist.
Anyone has a best practice on this or has done this before?You mean hat it returns every first name that is a substring of the name you look for?
Something like:

Where SearchString Like '%' + FirstNameField + '%'

I believe that would return, Antony, Tony, Ton, A, but not Abby and George.|||I presume iot is more complex that that yes? "Dick" for "Richard" and "Teddy" for "Edward"?|||I presume iot is more complex that that yes? "Dick" for "Richard" and "Teddy" for "Edward"?

Yes, Antony clearly wasnt the best choice.

I need Richard Bigglesworth to be returned when I look for Dick Bigglesworth!

Thanks for getting back on this.|||Use my fuzzy-search algorithm. It was created to do exactly what you describe.
http://sqlblindman.googlepages.com/fuzzysearchalgorithm

Example:
set nocount on
select dbo.comparetext('Antony Bigglesworth', 'Tony Bigglesworth') as CompareValue1
select dbo.comparetext('Richard Bigglesworth', 'Dick Bigglesworth') as CompareValue2

Results:
CompareValue1
----
94

CompareValue2
----
74|||Thanks Blindman,

That looks great.

I also have to define a group of names which would be specificly checked and collected then returned from the database. Thus, the user would look for "Tony" as the first name, and so all the people with first name "Tony" and all the people with the first name "Anthony" would be returned.

I kind of did it now, created a table where you can add in these name groups, and a small sql script then checks if the sought after first name is in the table, if it is it gets the group id, then cycles through the group collecting all the relevant records then returns them.

Thanks for all the help on this|||To be thorough, you should accept the names "Buddy" and "Pal" and perhaps "Dude" as wild-cards that match any name.|||don't forget "Todd" and "Biff"|||In SoCal, we also have to expand a bit on Blindman's suggestion, since we also have "Duuuuuude!" as well as any name with the suffix "meister" appended (as in "Paulmeister" or "Blindmanmeister").sql

No comments:

Post a Comment