write a sql query for searching using pattern matching.
my query is SELECT * FROM tbl_candidate WHERE `job_title` LIKE '%%' OR `candidate_city` LIKE '%glassboro%'.
it gives wrong output
write a sql query for searching using pattern matching.
my query is SELECT * FROM tbl_candidate WHERE `job_title` LIKE '%%' OR `candidate_city` LIKE '%glassboro%'.
it gives wrong output
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jignesh KumarRank #91 · 22.9K reputationPosted Nov 1, 2021, 5:50 AM EDT
Hi Ankita,
You can refer below link which will help you out,
declare @job_title varchar(100)
declare @candidate_city varchar(100)
set @candidate_city = 'glassboro'
SELECT * FROM tbl_candidate WHERE
(@job_title IS NULL OR job_title LIKE '%' + @job_title + '%')
AND (@candidate_city IS NULL OR candidate_city LIKE '%' + @candidate_city + '%')
https://sqlwithmanoj.com/2011/12/30/creating-stored-procedures-with-dynamic-search-filter/
Sachin SinghRank #66 · 26.2K reputationPosted Nov 1, 2021, 5:39 AM EDT
Ankita Kumari71 reputationPosted Nov 1, 2021, 3:21 AM EDT
Srinivasan RamamoorthiRank #877 · 2.5K reputationPosted Nov 1, 2021, 5:00 AM EDT