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.
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|0123456789012last 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 = 15So 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 aboveJohnny and Jack are within 13 charactersand Jack and Joe are within 12 so are SQL string should return okPlease 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 Dist2FROM CustomersWHERE (((InStr([CompanyName],"Jack")-(InStr([CompanyName],"Johny")+4))<15) AND ((InStr([CompanyName],"Joe")-(InStr([CompanyName],"Jack")+3))<15)); |
 |
|
|
|
|