I have query similar to the question in the link given below.
problem is that , the query returns all rows irrespective of searched term. Not only I get pname starting with D, but even all those which do not have D, only success is that results have rows which have starting letter as 'D' are on the top of the result. How can I avoid that?
Have you tried something like this (according to post you have mentionned) :
SELECT
pname, pdescription, price
FROM
products
WHERE pname LIKE '%D%'
ORDER BY
CASE
WHEN pname LIKE 'D%' THEN 1
ELSE 2
END;
Pay attention to WHERE clause