在数据库列中查找数据。 [英] Find Data in a database Column.
问题描述
我想从数据库中检索匹配列包含'single-101'的记录。
i我在匹配列中存储多个值,如single-101,单102,单103等。它也可能只包含单个值,如'单101'。
i知道怎样撤退时它是匹配列中的单个值:
OleDbCommand cmd = new OleDbCommand(select * from Table1 where match ='single-101',con);
但是如果匹配列中有多个值,那该怎么办呢?那么我知道上面的查询将无效。
请建议我怎么做...
我会非常感谢你的。你正在使用OleDB吗?
SELECT *
FROM 表1
WHERE 匹配赞 ' single - *'
尝试:WHERE匹配'%single-101 %'
这将找到包含'single-101'的所有记录,即使它之前或之后有什么东西。
HI,
您可以在查询中使用Like运算符。
SELECT * FROM 表1
WHERE 匹配赞 ' %single - %'
或
SELECT * FROM 表1
WHERE 匹配赞 ' * single - *'
了解更多有关如何使用的详细信息'喜欢'访问
for sql database
SQL LIKE Operator [ ^ ]
http://msdn.microsoft.com/en-us/library/ms179859.aspx [ ^ ]
使用访问数据库时
http:// www。 techonthenet.com/access/queries/like.php [ ^ ]
http://office.microsoft.com/en-in/access-help/like-operator-HP001032253.aspx [ ^ ]
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.
You're using OleDB, so i guess it's an Access database...
Try this:
SELECT * FROM Table1 WHERE match Like 'single-*'
Try: WHERE match like '%single-101%'
This will find all records that contain 'single-101' even if there is something before or after it.
HI,
you can use Like operator in your query for your purpose.
SELECT * FROM Table1 WHERE match Like '%single-%'
or
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[^]
这篇关于在数据库列中查找数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!