Click here to Skip to main content
15,922,325 members
Please Sign up or sign in to vote.
2.89/5 (2 votes)
See more:
i want to retrieve that records from database in which match column contains 'single-101'.

i am storing multiple values in match column like single-101,single-102,single-103 etc. And it is also possible that it can contain only a single values like 'single-101'.

i know how to retreive when it is single value in match column :

OleDbCommand cmd = new OleDbCommand("select * from Table1 where match = 'single-101'", con);

but what if there are multiple values in the match column.. Then i know above query will not work.

Please suggest me how to do this...

I will be very thankful of yours.
Posted

You're using OleDB, so i guess it's an Access database...

Try this:
SQL
SELECT *
FROM Table1
WHERE match Like 'single-*'
 
Share this answer
 
v2
Try: WHERE match like '%single-101%'
This will find all records that contain 'single-101' even if there is something before or after it.
 
Share this answer
 
HI,

you can use Like operator in your query for your purpose.

SQL
SELECT * FROM Table1
WHERE match Like '%single-%'


or

SQL
SELECT * FROM Table1
WHERE match Like '*single-*'



for more details on how to use 'Like' visit

for sql database

SQL LIKE Operator[^]

http://msdn.microsoft.com/en-us/library/ms179859.aspx[^]

when using access database

http://www.techonthenet.com/access/queries/like.php[^]

http://office.microsoft.com/en-in/access-help/like-operator-HP001032253.aspx[^]
 
Share this answer
 
if you want selected then also you can use this
SQL
SELECT *
FROM Table1
WHERE match in ('single-101','single-102')
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900