PHP MySQL Search And Order By Relevancy

后端 未结 5 594
[愿得一人]
[愿得一人] 2020-12-09 19:12

I know how to do a regular php mysql search and display the results. However, because of the nature of what I\'m trying to accomplish I need to be able to sort by relevancy.

5条回答
  •  粉色の甜心
    2020-12-09 19:46

    I Don't What exactly you want but the following code definitely work for you.

    SELECT ("some text here" or `column_name`) RLIKE "Apple|Iphone|Application" AS Result ORDER BY Result DESC;
    

    Separate all words with Bar(|) but results will be 1 or 0 founded or not resp. If you want to get founded rows see below.

    SELECT * FROM "table_name" WHERE `column_name` RLIKE "Apple|Iphone|Application";
    

提交回复
热议问题