Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

sql

select

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!

like image 986
DRastislav Avatar asked Mar 10 '13 15:03

DRastislav


2 Answers

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

select * from table where Name like '%es'
like image 55
John Woo Avatar answered Oct 02 '22 23:10

John Woo


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'

like image 29
NDJ Avatar answered Oct 02 '22 21:10

NDJ