Forum Moderators: coopster
2. use regular expression:
.....where field1 REGEXP '[[:<:]]$searchword[[:>:]]'";
3. use mysql's full-text searching
Are there any other methods? I would like to make sure that I know all the possible options so I could choose one that works best in my case.
Log each search word, or those which didn't return any output, into a db
and then manually put the word that should be searched as well.
CREATE TABLE searches(searched VARCHAR(50), tosearch VARCHAR(50));
The query would look sth like this:
$sql = "IF((SELECT searched FROM searches WHERE searched='$searchword') IS NULL) THEN (INSERT INTO searches(searched) VALUES('$searchword'))";
//I'm not really sure about this, but I wanted to add to a database a word, that is not already there.
//query the db//here the search query
$sql = "(SELECT field1 FROM table WHERE field1 LIKE '%$searchword%') UNION (SELECT table.field1 FROM table, searches WHERE field1 LIKE '%searches.tosearch%' AND searches.searched='$searchword')"
This shall do
Best regards
Michal Cibor