Hi guys... In my db i have a row where the field 'term' is 'pick-up' and a row where the field 'term' is 'pick-something-up'. in my php script I have a variable called $term with 'how-to-pick-up-apples'. When I run this query: $result = mysql_query("SELECT * FROM data WHERE MATCH (term) AGAINST ('$term' IN BOOLEAN MODE)"); PHP: it selects either of the rows in my database, depending on which row comes first. I'd like it only to select the row, where there was an exact match. Meaning that only the row with 'pick-up' should be selected and not the row with 'pick-something-up'. How do I do that?
Then why you are matching in BOOLEAN MODE? If you want to look for 'pick-up' then AGAINST ('pick-up') should do the trick. If you want to do queries like '+word1 +word2 -word3' then you need the boolean mode.
Okay, that makes sense. Thx. But using: $result = mysql_query("SELECT * FROM data WHERE MATCH (term) AGAINST ('$term')"); PHP: ...only gives NULL values. Could it have something to do with the hyphen in the words? And btw, I'm looking for 'pick-up' inside the 'how-to-pickup-apples' sentence.
It looks like dash (-) is some non-word character in your charset. You should do some hacks to /mysql/share/charsets files to override it somehow... In your case you should use IN BOOLEAN MODE or IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION