mysql - full text search excluding a specific criteria -


i have table called items , enabled full text searching on name column

  id         name             price  ----       ------           -------   1          brown wood       550   2          black wood       430   3          wooden chair     15   4          kitchen knife    3   5          sponge ball      1.35 

i want write query select items whom name doesn't include 'wood' using full text search

so result be

  id         name             price  ----       ------           -------   4          kitchen knife    3   5          sponge ball      1.35 

here query

 select * items match(name) against('-wood' in boolean mode); 

if don't want wood, fist stab @ query be:

select * items match(name) against('-wood*' in boolean mode); 

however, - works after other terms matched. so, need sort of positive match. like:

select * items match(name) against('k* , -wood*' in boolean mode); 

if know such exclusions common, might include particular word in every name (say, "name"). alternatively, might need resort like:

select * items concat(' ', name' not '% wood%'; 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -