Mysql free text search

Mysql free text search

select
    concat(`make`, ' ', `model`, ' ', `style`, ' ', `transmission`, ' ', `exterior_color`) as v,
    match
        (`make`, `model`, `style`, `transmission`, `exterior_color`, `vehicle_features`, `body_style`)
    against
        ('BMW Black'  IN BOOLEAN MODE) as r
from
    vehicles
where
    match
        (`make`, `model`, `style`, `transmission`, `exterior_color`, `vehicle_features`, `body_style`)
    against
        ('BMW Black'  IN BOOLEAN MODE)

 
You would have to add fulltext index to make this working.

ALTER TABLE `vehicles` ADD FULLTEXT `search` ( `make` , `model` , `style` , `exterior_color` , `body_style` , `transmission` , `vehicle_features` ) ;

 

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *