I am trying to compose an SQL SELECT query with a few search words. But I want the result to be ordered by the number of word matches.
For example, let the search string be "red green blue." I want the results to contain all these three words on top, after which the results contain two of them, and in the end - only one word.
SELECT
*
FROM
table
WHERE
(col LIKE '%red%') OR
(col LIKE '%green%') OR
(col LIKE '%blue%')
ORDER BY
?????
Thanks in advance!
source
share