Reputation: 175
I want to select titles that have a number after a certain character. Example:
SELECT * FROM table WHERE title LIKE '%- H(any number)'
How would I select any number in this statement 1-10000000 if the number exists?
Upvotes: 10
Views: 14604
Reputation: 65304
SELECT * FROM table WHERE title RLIKE '- H[:digit:]{1,7}$';
will give you 1-9999999
Upvotes: 4
Reputation: 324750
SELECT * FROM table WHERE title REGEXP '.*- H[0-9]+'
That seems like the kind of thing you're looking for.
Upvotes: 9
Reputation: 183456
Use a regular expression:
SELECT ...
FROM table
WHERE title REGEXP '- H([1-9][0-9]{0,6}|10000000)$'
;
Upvotes: 1