如何使用Like运算符从单个表中获取两列 [英] How to get two columns from single table using Like operator
本文介绍了如何使用Like运算符从单个表中获取两列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用Like运算符从单个表中获取两列
我尝试下面的一个它不工作.... < br $> b $ b
How to get two columns from single table using Like operator
I tried below one it's not working....
create proc spName
@firstName nvarchar(50),@lastName nvarchar(50)
as
Begin
select FirstName,LastName from Employee
where FirstName like @firstName + '%' or LastName like @lastName + '%'
End
谢谢,
bajid
Thanks,
bajid
推荐答案
在使用括号的where子句之后它正在工作......... 。
After where clause using brackets it's working..........
create proc spName
@firstName nvarchar(50),@lastName nvarchar(50)
as
Begin
select FirstName,LastName from Employee
where (FirstName like @firstName + '%') or (LastName like @lastName + '%')
End
试试这个
Try this
select FirstName,LastName from Employee
where FirstName like @firstName +'%'
union select FirstName,LastName from Employee where
LastName like @lastName +'%'
这篇关于如何使用Like运算符从单个表中获取两列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文