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

word search

Status
Not open for further replies.

Hameedullah

Programmer
Aug 12, 2002
29
0
0
AU
Hi everyone,

I am having difficulty with writing a search function that searches the database for keywords. How can I write a sql query so that it returns those records that contain the keyword as a word not part of a word.

I tried using wildcards like this
Code:
select * from mytable where title like '% keyword %' or title like '% keyword,%' or title like '% keyword.%' or title like '% keyword!%'

This will only return those records that have the keyword delimited by space or space and a punctuations. It wont return any results if the keyword is mentioned in the start of or end in that field. Any suggestions?

PS: Can't do fulltext search on the database

You are either the slave of what made men or what men made.
 
hi, can you write a example ? something like "I have this record.... and wanna get this..."

regards, Camaleon CHILE
 
Why not add those too as part of the search criteria?
Code:
title like 'Keyword %'
or title like '% keyword'

Regards,
AA
 
I found a solution guys... thanks.

I used another field and put all the keywords "with a preceding and trailing spaces" like " adsl modems netcomm " for a record that had Netcomm ADSL Modems. Doing search of that new field rather than title.

You are either the slave of what made men or what men made.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top