I'm working on seach function where request is coming from front end with the wild card and based on the request it should output desired outcome.
Let's say we have a Name colum In DB with some records:
Name
---------
political party Delhi, IN (ruling)
political party Mumbai, IN (ruling)
political party Kerala, IN (not ruling)
political party Goa, IN (ruling)
Now from JSP page request is coming as *Del*ruling* (or request could come just as *Del*)
and outcome should be: political party Delhi, IN (ruling).
I spent few days but could not find how to implement this functionality. Any guidance will be highly appreciated.
MySQL supports wildcards. They are denoted by the % character and used in a LIKE statement. So just replace all '*' with '%' and you're good to go!
SELECT *
FROM articles
WHERE body LIKE '%Del%ruling%'