SQL - how to select words with certain values at the end of word

邮差的信 提交于 2019-12-19 05:17:52

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!