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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search database for whole word

Status
Not open for further replies.

guitardave78

Programmer
Sep 5, 2001
1,294
GB
Is it possible to search a database using a regular expression. I use
strSQL = "SELECT * FROM qry_search WHERE search like '" & searchString & " %' ORDER BY date_added"

and some script to put spaces around the search terms, but i want to be able to search for whole words
Any ideas?
 
I guess you can do this "Keywords, LIKE '% " & searchString & " %'", but when you build this query, you might also want to create a loop (you can use the mid function) that will separate the SearchString into just whole words. Then you also have to decide if each "search word unit with the SQL LIKE" should have "and" or "or" relation. Some search engines offer the user this option to pick from, others have one of those two hardcoded.
 
yeah i have all that built in but i was trying to see if there is a better search method lol
 
There may also be a stored procedure already built into SQL Server (if that is what you are using) that may help with this as well. (Or else I'm just making things up, which is never entirely impossible when I rely on my faulty memory.) For more assistance, you can try forum183.

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top