Skip to content
Advertisement

SQL, like, after characters

It’s possible to do a LIKE SQL after some characters?

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. For the fourth sentence, i added ” ANSWER” should not itself return because the regex is ” A” and not ” A%”

Do you have an idea?

Advertisement

Answer

Simply include the colon in your LIKE expression.

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

or, adjust your text slightly:

select *
from yourtable
where yourcolumn+' ' like '%:%A %'
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement