日期:2014-05-20 浏览次数:20676 次
if not object_id('tempdb..#Student') is null begin drop table #Student end create table #Student(stu_id nvarchar(36),stu_name nvarchar(36),stu_class nvarchar(36)) insert into #Student select '1','a','b' union all select '2','b','b' union all select '3','c','b' union all select '4','d','c' union all select '5','e','d' select * from #Student where stu_id='c' or stu_name='c' or stu_class='c' /* 3 c b 4 d c */
------解决方案--------------------
如果是模糊查询,就用各个字段 like '%输入的信息%',然后or各个条件就可以了
如果是精确查询,就用各个字段 = '输入信息',然后or各个条件
for example
--模糊查询 select * from student where stuID like '%' || your_text || '%' or stuName like '%' || your_text || '%' or [class] like '%' || your_text || '%' --精确查询 select * from student where stuID = your_text or stuName = your_text or [class] = your_text