Order SQL by strongest LIKE?

后端 未结 3 699
有刺的猬
有刺的猬 2020-12-12 19:45

I have the following query:

SELECT * FROM table_name
WHERE (col_1 LIKE \'%$keyword%\'
    OR col_2 LIKE \'%$keyword%\'
    OR col_3 LIKE \'%$keyword%\')
  AN         


        
3条回答
  •  时光说笑
    2020-12-12 20:15

    You can't. You're asking your RDBMS to sort results by rows with the most "LIKE" column matches descending.

    MySQL, for instance, does this with what's called a FULLTEXT index.

提交回复
热议问题