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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh KumarPosted Nov 1, 2021, 9:50 AM
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 SinghPosted Nov 1, 2021, 9:39 AM
Srinivasan RamamoorthiPosted Nov 1, 2021, 9:00 AM
Ankita KumariPosted Nov 1, 2021, 7:21 AM