I have a complex query that does multiple matches across multiple columns and then orders by relevance.
Everything works fine UNTIL I add WHERE 'rank' > 0
This then returns an empty results set.
If I remove the 'WHERE' statement then I can see all results with the highest matches at the top.
Could someone help me work out 'WHERE' :-D I am going wrong!!
SELECT *, CASE WHEN companyName = 'gfdgfs' THEN 2 ELSE 0 END
+ CASE WHEN companyName LIKE '%gfdgfs%' THEN 1 ELSE 0 END
+ CASE WHEN companyName = 'potato' THEN 2 ELSE 0 END
+ CASE WHEN companyName LIKE '%potato%' THEN 1 ELSE 0 END
+ CASE WHEN address1 = 'gfdgfs' THEN 2 ELSE 0 END
+ CASE WHEN address1 LIKE '%gfdgfs%' THEN 1 ELSE 0 END
+ CASE WHEN address1 = 'potato' THEN 2 ELSE 0 END
+ CASE WHEN address1 LIKE '%potato%' THEN 1 ELSE 0 END
AS rank
FROM clients
WHERE rank > 0
ORDER BY rank
EDIT
I removed the single quotes around the rank
word and now get 'unknown column rank in where clause'