So im trying to make a simple search feature, that orders the results by relevancy.
I found a query online, that said it did just that, but now im trying to run it, im getting a mysql error.
ERROR:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''posts' WHERE post_content LIKE '%test%' OR post_content LIKE '%string%' ORDER B' at line 1
QUERY:
SELECT *, ((CASE WHEN 'post_content' LIKE '%test%' THEN 1 ELSE 0 END) + (CASE WHEN 'post_content' LIKE '%string%' THEN 1 ELSE 0 END)) AS relevance FROM 'posts' WHERE post_content LIKE '%test%' OR post_content LIKE '%string%' ORDER BY relevance DESC
Can anyone shed some light on what this error is about?
Question
mikeaag
Hey,
So im trying to make a simple search feature, that orders the results by relevancy.
I found a query online, that said it did just that, but now im trying to run it, im getting a mysql error.
ERROR:
QUERY:
Can anyone shed some light on what this error is about?
Thanks in advance :D
Link to comment
Share on other sites
3 answers to this question
Recommended Posts