Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get string ending with zero or more digits

Tags:

sql

sql-server

I am trying to write a query which returns string ending with zero or more digits.

For example, I have strings 'amit', 'amityy', 'amit001'. I want to only return 'amit' and 'amit001'.

I tried LIKE 'amit%', but not get success.

like image 736
user100 Avatar asked May 02 '26 12:05

user100


1 Answers

Checks if the string starts with amit and that there are only numbers after amit:

LIKE 'amit%' AND NOT LIKE 'amit%[^0-9]%'
like image 84
Andomar Avatar answered May 04 '26 14:05

Andomar