Hameedullah
Programmer
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
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.
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.