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.
Loading
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.
Piyush PansuriyaPosted Jan 12, 2015, 8:59 AM
AlbertPosted Jan 12, 2015, 8:32 AM
Rajesh PathakotiPosted Jan 12, 2015, 8:22 AM
Piyush PansuriyaPosted Jan 12, 2015, 8:11 AM
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.