我需要标识FirstName中包含A&B或B、C等值的所有记录
有没有一种方法可以识别这些记录?我现在有这个,但它并不能让我达到这个目标:
select * from #temp
WHERE FirstName LIKE '%[a-z] [a-z]%' or
FirstName LIKE '%[a-z] & [a-z]%'
示例代码:
Create table #temp
(
FirstName varchar(50)
)
insert into #temp
(
FirstName
)
select
'Mary Smith'
union
select
'John'
union
select
'Bob'
union
select
'Bruce'
union
select
'Sally'
union
select
'A & B'
union
select
'B C'
select * from #temp
drop table #temp
发布于 2019-05-16 03:59:10
如果从like
表达式(%)中删除通配符,它将与当前测试数据匹配,例如
select *
from #temp
where FirstName like '[a-z] [a-z]'
or FirstName like '[a-z] & [a-z]';
https://stackoverflow.com/questions/56160456
复制