Można użyć REGEXP
i klasę postaci
select * from table where item REGEXP '[[:digit:]]$'
DEMO
Objaśnienie:
[[:digit:]] >> Match digit characters
$ >> Match at the end of the string
W. w wyrażeniu nawiasowym (napisanym przy użyciu [i]), [: character_class:] reprezentuje klasę znaków, która pasuje do wszystkich znaków należących do tej klasy.
Sidenote:
Inne klas postaci mysql osób do korzystania z REGEXP
, zaczerpnięte z documentation:
Character Class Name Meaning
alnum Alphanumeric characters
alpha Alphabetic characters
blank Whitespace characters
cntrl Control characters
digit Digit characters
graph Graphic characters
lower Lowercase alphabetic characters
print Graphic or space characters
punct Punctuation characters
space Space, tab, newline, and carriage return
upper Uppercase alphabetic characters
xdigit Hexadecimal digit characters
tylko ostatni znak lub wielu znaków? –
zobacz: http: //stackoverflow.com/questions/12911526/any-way-to-select-from-mysql-table-where-a-field-ends-in-certain-character-numbe –