📜  mysql search like order by best match - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:29.485000             🧑  作者: Mango

代码示例1
SELECT word
FROM words
WHERE word LIKE '%searchstring%'
ORDER BY
  CASE
    WHEN word LIKE 'searchstring%' THEN 1
    WHEN word LIKE '%searchstring' THEN 3
    ELSE 2
  END