I have an SQL search function built up as following:
SELECT
*
FROM
Table
WHERE
Question LIKE @SearchString
OR Answer LIKE @SearchString
OR Keywords LIKE @SearchString
And I want to order them by relevance, meaning the results where Keywords LIKE @SearchString on top, followed by Answer LIKE @SearchString and then Question LIKE @SearchString. But I can't seem to figure out how despite several googling efforts.
I found somewhere that
ORDER BY
CASE
WHEN CHARINDEX(FAQ_FAQ.Keywords, @SearchString, 1) > 0 THEN 0
ELSE 1
END ASC,
Might work, but apparently it doesn't.
Thx in advance