How to use both "like" and "=" in select statment.
here is the query "select * from tblxyz where name like @a1 or mob like @a2 and city = @a3"
What is the right method to use these type of queries.
please reply soon.
How to use both "like" and "=" in select statment.
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Piyush PansuriyaRank #454 · 5.5K reputationPosted Jan 12, 2015, 3:11 AM EST
When you want records which are containing your word than you have to use like.
i.e.
select * from tblxyz where name like '@a1'
select * from tblxyz where name = '@a1'
both statement returns same data.
Now,
select * from tblxyz where name like '@a1%'
it will returns that records which are starts from @a1.....
select * from tblxyz where name like '%@a1%'
it will returns that records which are containing .....@a1.....
You can not use '%' with "=".
"=" Returns exact matches data.
Rajesh Pathakoti161 reputationPosted Jan 12, 2015, 3:22 AM EST
Albert37 reputationPosted Jan 12, 2015, 3:32 AM EST
Piyush PansuriyaRank #454 · 5.5K reputationPosted Jan 12, 2015, 3:59 AM EST