Mysql full text search "all but" query

I need to query a table for "everything but a keyword". Using just "-" doesn't work and in fact the mysql manual says:

Note. The - operator only acts to exclude strings that are otherwise similar to other search terms. Thus, a boolean search containing only conditions that are preceded will return an empty result. It does not return "all rows" except those containing excluded terms. "

The only workaround I found was "a * b * .... y * z * -keyword" as this allows all other results to be matched. Is there another (cleaner) way?

+1


source to share


1 answer


Just use:



NOT MATCH(field) AGAINST(keyword)

      

+1


source







All Articles