简体   繁体   English

SQL,like,后字符

[英]SQL, like, after characters

It's possible to do a LIKE SQL after some characters?可以在某些字符之后执行 LIKE SQL 吗?

Exemple:

" Arthur is wanted : A test"

" Arthur is wanted : B"

" Arthur is wanted : BE COOL A"

" Arthur is wanted : ANSWER B"

I wanted "LIKE" sql after ":" with " A" So, REGEX like should be return only the first and third sentence.我想要在“:”和“A”之后的“LIKE”sql 所以,REGEX like 应该只返回第一句和第三句。 For the fourth sentence, i added " ANSWER" should not itself return because the regex is " A" and not " A%"对于第四句,我添加了“ANSWER”本身不应该返回,因为正则表达式是“A”而不是“A%”

Do you have an idea?你有想法吗?

Simply include the colon in your LIKE expression.只需在 LIKE 表达式中包含冒号即可。

select *
from yourtable
where yourcolumn like '%:%A %'
OR  yourcolumn like '%:%A'

or, adjust your text slightly:或者,稍微调整一下你的文字:

select *
from yourtable
where yourcolumn+' ' like '%:%A %'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM