tags:

views:

94

answers:

3

Beginning with a letter I know how to do:

WHERE mov_title REGEXP CONCAT('^(the )?', '$letter')

And this method will work if I substitute $letter with any number, so if its set to 1, it will find all records that begin with 1, but I need it to work for any number 0-9. How could I modify the query?

+4  A: 
WHERE mov_title REGEXP '^(the )?[0-9]'

(Or set $letter to [0-9] if you want to keep using your existing WHERE clause.)

LukeH
+2  A: 

Another option may be to use the substring function

WHERE substring( post_title, 1, 1 ) between '0' and '9'
kdmurray
+1  A: 

Perhaps SQL Wild cards [charlist] might help:

http://w3schools.com/sql/sql_wildcards.asp

adam