Reputation: 465
I have one database table name test123
and having column name
. And it contains the data like 'nir,kal,man'
Now, when i am querying the table with select statement as per below :
select * from test123 where name = 'nir,kal,man';
But this will not return any result...Why this happened.? How i have to write query so that will return the result? I am using Sql server 2008.
Thanks...!
Upvotes: 4
Views: 751
Reputation: 4697
=
operator returns exact match, so if your cell contain data "like" that you need to use LIKE
operator:
select * from test123 where name like '%nir,kal,man%'
where %
will be replaced with any set of characters.
Also check that you're targeting correct database by using full name
select * from yourdb.dbo.test123 where....
Upvotes: 5
Reputation: 1720
if Nir is in first row Kal in 2nd row and man is in 3rd row then you should write query like this
select * from test123 where name in ('nir','kal','man')
Upvotes: 3