Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

searching/parsing

Status
Not open for further replies.

TheConeHead

Programmer
Aug 14, 2002
2,106
US
I want to have a page that searches a particular column in a sql 7 DB for say like a keyword.... any guidance on this?
 
Hey ConeHead,

You can use several different search types. The most widely used is the LIKE function

ie:

SELECT * FORM someTable WHERE Keywords LIKE '%keyword%'

but there are other methods for searching and matching.. I generally use both the LIKE and the SOUNDS LIKE functions such as SOUNDEX and DIFFERENCE.

SOUNDEX and DIFFERENCE are very useful if spelling may be an issue. Since many people may spell certain words (such as first/last names, cities, and such) differently, SOUNDEX and DIFFERENCE can match, for example, "BRIAN" with "BRYAN".

Here is an example SOUNDEX/DIFFERENCE SQL statement:

cmd.commandtext = "SELECT * FORM someTable WHERE DIFFERENCE(keyword, '" & request.form("keyword") & "') => 3 or Keyword LIKE '%" & request.form("Keyword") & "%'"

The Difference will return a a value ranging from 0 to 4.. 4 being the highest possible match meaning it is exactly the same and 0 meaning it does not match at all. What we are doing in the above search is looking for anything that ranks a 3 or higher. This brings back a fairly accurate match.

Hope this helps,

Cheers,

Gorkem.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top