Page 1 of 1

a query issue

Posted: Wed Feb 14, 2007 4:49 am
by itsmani1
my table has 2 columns id and name
i want to select all those names that start with a number [0-9] using a query is this possible?

for example for selecting all the names starting with A i am doing this:

Code: Select all

name LIKE 'A%'
I need help to select name starting with number like "100 5 The Zones Acoustic Xmas" etc

thank you

Posted: Wed Feb 14, 2007 5:49 am
by Chris Corbyn
You can use regular expressions.

Code: Select all

SELECT foo FROM tbl_name WHERE name REGEXP '^[0-9]'

Posted: Wed Feb 14, 2007 6:00 am
by itsmani1

Code: Select all

SELECT * 
FROM mk
WHERE EventName LIKE REGEXP '^[0-9]%'
LIMIT 0 , 30
Error:
MySQL said:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'REGEXP '^[0-9]%'
LIMIT 0, 30' at line 1

Posted: Wed Feb 14, 2007 7:27 am
by feyd
There's no LIKE when working with REGEXP.