如何在一个查询中使用IN和LIKE这两个SQL Server命令在一个查询字符串中 [英] How to use IN and LIKE both commands of sql server in one query for searching string
本文介绍了如何在一个查询中使用IN和LIKE这两个SQL Server命令在一个查询字符串中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在一个查询中使用sql server的IN和LIKE这两个命令来搜索字符串?是的,我的编码问题是.如果我将一个句子放在一个文本框中,所有单词将一一检查像Google搜索一样.它将在datagridview中显示所有相关数据.
先生,我想这样写.但这不正确.我的编码是:
How to use IN and LIKE both commands of sql server in one query for searching string?Yes i checked.My question in that coding is.if i will put one sentence in one textbox that all the words will check one by one like google search.and it will display all related datas in datagridview.
Sir i want to put like this.but it is not correct.My coding is:
select *from CandidateDetails where like (% '"+textBox.Text+"'%) IN (firstname,lastname,middlename)
推荐答案
喜欢,请参阅此-
http://msdn.microsoft.com/en-us/library/ms179859.aspx [ ^ ]
对于IN来说,这是
http://msdn.microsoft.com/en-us/library/ms177682.aspx [ ^ ]
For LIKE see this -
http://msdn.microsoft.com/en-us/library/ms179859.aspx[^]
and for IN see this -
http://msdn.microsoft.com/en-us/library/ms177682.aspx[^]
尝试这个
select * from CandidateDetails where FirstName in (''ra'') or LastName like ''%ul%''
检查 this [
Check this[^] thread. I feel you are looking for same thing.
Update: I assume that the there are column names after the in clause.
select *
from CandidateDetails
where (firstname like (% ''"+textBox.Text+"''%)) OR
(lastname like (% ''"+textBox.Text+"''%)) OR
(middlename like (% ''"+textBox.Text+"''%)))
这可能会有所帮助.
This may help.
这篇关于如何在一个查询中使用IN和LIKE这两个SQL Server命令在一个查询字符串中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文