如何在sql server中使用类似的查询 [英] how to use like query in sql server
问题描述
表如下(表名常见问题)
类别问题答案
管理员你有吗预订课程的权利?是的
管理员在什么时候上课? 2PM
软件所有课程照片是否必要?是
设计页面如下
两个单选按钮如下
按字(RadioButton1)按类别(RadioButton2)
然后我有一个文本框(Textbox1)
然后我有一个搜索按钮
首先我选择按字(RadioButton1)然后在textbox我输入课程(从表格(FAQ))然后我点击gridview显示中的搜索按钮如下
从表格(FAQ)想检查单词当然有吗?
在gridview中如下
类别问题答案
管理员你有权预订课程吗?是
软件所有课程照片是否必要?是的
因为在表(FAQ)课程中有词。
为什么能写出类似查询的sql
匹配来自表格常见问题。
如何根据我的要求编写类似查询的sql。
问候,
Narasiman P.
Table as follows (Table Name FAQ)
Category Questions Answers
Admin do you have rights to book course? Yes
Admin at what time class starts? 2PM
Software All course photo is necessary? Yes
Design page as follows
Two Radio Button as follows
By Word (RadioButton1) By Category (RadioButton2)
Then i have one textbox(Textbox1)
Then i have one Search Button
First i select the By Word(RadioButton1) Then in the textbox i type course(from the table(FAQ)) then i click the Search Button in gridview display as follows
From the table (FAQ) want to check the word course is there?
In gridview as follows
Category Questions Answers
Admin do you have rights to book course? Yes
Software All course photo is necessary? Yes
Becuase in the table(FAQ) course word is there.
for that how can write the sql like query
matching the word course from the table FAQ.
how can i write the sql like query for my requirement.
Regards,
Narasiman P.
推荐答案
喜欢非常简单:它与=几乎相同,但带有外卡。 />
在你的情况下,最有用的通配符可能是%,它匹配任何字符的零或更多,就像windows文件名中的*一样。
所以,如果你有一张包含标题的表:
Like is pretty simple: it'a pretty much the same as "=" but with wild cards.
In your case, the most useful wildcard is probably "%" which matches zero or more of any character, much as "*" does in windows filenames.
So if you have a table contains Titles:
The Cat sat on the mat
The Cat who looked at a king
Cats a furry
The ArtistoCat
All about Dogs
然后:
Then:
SELECT Title FROM MyTable WHERE Title LIKE '%Cat%'
将返回前四名标题,但不是最后一个。
would return the top four titles, but not the final one.
从FAQ中选择QuestionColumn,其中NameofColumnWherecourseWordIsPresent如'%course%'
select QuestionColumn from FAQ where NameofColumnWhere"course"WordIsPresent like '%course%'
Check 这个。
这篇关于如何在sql server中使用类似的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!