Mysql like and BOOLEAN MODE (FULLTEXT) search

前端 未结 2 609
盖世英雄少女心
盖世英雄少女心 2020-12-18 11:46

I\'m trying to write a query to search for a record using a wild card.

I have two queries below which works but I like to know which one of the is more optimise.

2条回答
  •  天涯浪人
    2020-12-18 12:10

    Query one does gives me what i'm looking for but query two gives me different results.

    WHERE name LIKE '%County Down%'

    WHERE match( name ) AGAINST ( '%County Down%' IN BOOLEAN MODE )

    The first query will return results for "LACounty Down" and "NYCounty Down", but the second query will not return these results. Both queries will return results like "LA County Down" and "NY County Down," though.

    To make the results match and to have it return these "fuzzy match" results, change your second query to...

    WHERE match( name ) AGAINST ( '*County Down*' IN BOOLEAN MODE )
    

提交回复
热议问题