Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 HASH difference looking at all words in a field

Author  Topic 

cwfontan
Yak Posting Veteran

87 Posts

Posted - 2009-06-10 : 11:46:57
i want to compare my value to all words in a particular field using the difference?

any suggestions ? I already tried '%McDonalds%' but any suggestions welcome.

 
tbl1
col1Name | col2State
Company name is McDonalds | NC


SELECT col1Name, DIFFERENCE(col1Name, 'McDonalds') AS difference
FROM dbo.tbl1
WHERE (DIFFERENCE(col1Name, 'McDonalds') >= 2)
ORDER BY difference DESC

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-06-10 : 13:07:38
If you want to see if 'McDonalds' exists in the column1, e.g, 'Old McDonalds Farm', use
where col1Name like '%McDonalds%', otherwise the two values will never be alike using difference unless they're equal.

Jim
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-10 : 14:09:42
can you explain you requirement? are you looking for wildcard match or fuzzy match?
Go to Top of Page

cwfontan
Yak Posting Veteran

87 Posts

Posted - 2009-06-10 : 14:23:43
quote:
Originally posted by visakh16

can you explain you requirement? are you looking for wildcard match or fuzzy match?



well i have a string and I want to find the best match in the database
in the example below the best match would be record 2


[Code]
string may be "Dupont wharehouse houston TX"

database will have
nameCol | cityCol | stateCol
Dupont containers Inc | Houston | TX
Dupont Wharehouse A | Houston | TX
Dupont Wharehouse | Chicago | IL

[\code]


if I can hear your sugestions on how to accomplish this.. that may be better than asking about the logic I have in my head.


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-10 : 14:26:15
so it seems like what you want is a wildcard search... so in above case you want all results to be returned or best match which is second record?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-10 : 14:39:59
See http://sqlblindman.googlepages.com/fuzzysearchalgorithm


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

cwfontan
Yak Posting Veteran

87 Posts

Posted - 2009-06-10 : 14:55:25
quote:
Originally posted by visakh16

so it seems like what you want is a wildcard search... so in above case you want all results to be returned or best match which is second record?



I would say best match.. and I will have to code some logic in that determines how many out of the 3 fields were matched to consider it a full match..

thanks
Go to Top of Page
   

- Advertisement -