Full text search vs LIKE

前端 未结 6 1648
长情又很酷
长情又很酷 2021-02-04 01:45

My question is about using fulltext.As I know like queries which begin with % never use index :

SELECT * from customer where name like %username%
6条回答
  •  -上瘾入骨i
    2021-02-04 01:55

    Like and contains are very different -

    Take the following data values

    'john smith' 'sam smith' 'john fuller'

    like 's%' 'sam smith'

    like '%s%' 'john smith' 'sam smith'

    contains 's'

    contains 'john' 'john smith' 'john fuller'

    contains 's*' 'john smith' 'sam smith'

    contains s returns the same as contains s* - the initial asterisk is ignored, which is a bit of a pain but then the index is of words - not characters

提交回复
热议问题