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

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'


You can also use REGEX

select distinct city from station where city REGEXP '[aeiou]$';

Resources: To Know more about REGEXP


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]'


You have to remove the last %, so it will only select words ending with es.

select * from table where Name like '%es'

Tags:

Sql

Select