Search code examples
phpwildcardagainst

mysql query against wildcard


I have a mysql query in php, using match / against to filter results. Im trying to get a wildcard after $string so the next character can be anything. Help?

"SELECT * FROM $table WHERE MATCH (message) AGAINST('$string%' IN BOOLEAN MODE)"

Solution

  • Use * instead of % as a wildcard when using MATCH (...) AGAINST (...):

    "SELECT * FROM $table WHERE MATCH (message) AGAINST('$string*' IN BOOLEAN MODE)"