mysql where string ends with numbers -


my table column contains values like:

id | item ------------- 1  | aaaa11a112 2  | aa1112aa2a 3  | aa11aa1a11 4  | aaa2a222aa 

i want select rows value of item ends numbers. there this?

select * table item '%number' 

you can use regexp , character class

select * table item regexp '[[:digit:]]$' 

demo

explanation:

[[:digit:]] >> match digit characters $           >> match @ end of string 

within bracket expression (written using [ , ]), [:character_class:] represents character class matches characters belonging class.


sidenote:

other helpful mysql character classes use regexp, taken 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, , carriage return upper                   uppercase alphabetic characters xdigit                  hexadecimal digit characters 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -