tpk
tpk

Reputation: 2131

mysql fulltext search "all but" query

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

Note: The - operator acts only to exclude rows that are otherwise matched by other search terms. Thus, a boolean-mode search that contains only terms preceded by - returns an empty result. It does not return “all rows except those containing any of the excluded terms.”

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

Upvotes: 1

Views: 594

Answers (1)

Robert Gamble
Robert Gamble

Reputation: 109102

Just use:

NOT MATCH(field) AGAINST(keyword)

Upvotes: 1

Related Questions