Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
itsmani1
Forum Regular
Posts: 791 Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:
Post
by itsmani1 » Wed Feb 14, 2007 4:49 am
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:
I need help to select name starting with number like "100 5 The Zones Acoustic Xmas" etc
thank you
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Wed Feb 14, 2007 5:49 am
You can use regular expressions.
Code: Select all
SELECT foo FROM tbl_name WHERE name REGEXP '^[0-9]'
itsmani1
Forum Regular
Posts: 791 Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:
Post
by itsmani1 » Wed Feb 14, 2007 6:00 am
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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Feb 14, 2007 7:27 am
There's no LIKE when working with REGEXP.