I am facing problem in order by, I am fetching the records from SQL DB based on the keyword with like, now I want all records should be return based on entered keyword order.
Example: If user enter “Physics” then it first return the Physics(exact word) if exists, after that return all another records.
SELECT *
FROM Subject SM
WHERE SM.SubjectName LIKE '%' + @SubjectName + '%'
ORDER BY @SubjectName DESC
How can I achieve this?
1 Answer