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
 Other Forums
 MS Access
 Adjacent search

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-01-30 : 08:18:10
Johnny writes "String Example:
Johnny, was Jack with and Joe they came to see us in New york
1234567890123|0123456789012
last weekend.

I have a Memo Field (Type) and I an doing the following
Search Withing the Memo more than on string.....

IE: "Johnny" And "Jack" And "Joe" But I would Like the SQL statement To return me only the cases where these words are in a specified distance of X.....

IE: X = 15
So the SQL search should return me the distance beetwen each word and if that distance is smaller than (15) then it is OK....
Else Ignore IT

In the example above
Johnny and Jack are within 13 characters
and
Jack and Joe are within 12 so are SQL string should return ok

Please could you guys help me with IT
Best Regards
Johnny"

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2003-01-30 : 09:14:55
SELECT Customers.*,
InStr([CompanyName],"Jack")-(InStr([CompanyName],"Johny")+4) AS Dist1,
InStr([CompanyName],"Joe")-(InStr([CompanyName],"Jack")+3) AS Dist2
FROM Customers
WHERE
(((InStr([CompanyName],"Jack")-(InStr([CompanyName],"Johny")+4))<15) AND
((InStr([CompanyName],"Joe")-(InStr([CompanyName],"Jack")+3))<15));


Go to Top of Page
   

- Advertisement -