问题
iam new to sql and i would like to know how can I find the letter or symbol at the end of value in column called Name
?
E.g if i would find something i will write select * from 'table' where 'Name' like '%es%'
but it will find me all rows contains es
Lets say - lesl, pespe, mess
... but how to write select which will select just values with 'es'
At the end of word? ... using regex
i will use es\Z
..... thanks in advance!
回答1:
You have to remove the last %
, so it will only select words ending with es
.
select * from table where Name like '%es'
回答2:
You're currently matching on: ..where 'Name' like '%es%'
.
Which equates to anything, then 'es' then anything else
.
Removing the last %
changes the where to
anything then 'es'
.
in short.. you need ..where 'Name' like '%es'
回答3:
The query ..where 'Name' like '%es' will find columns where name ends with "ES". But if we need to find column where name ends with either "E" or "S", the query would be
.. where 'Name' LIKE '%[ES]'
来源:https://stackoverflow.com/questions/15324012/sql-how-to-select-words-with-certain-values-at-the-end-of-word