LIKE question

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

LIKE question

Post by alex.barylski »

I have a small problem, not really important but still:

I want to find only the names of records whose start with the digits 0-9 using a SQL expression like:

Code: Select all

SELECT * FROM table WHERE LIKE '[0-9]%'
This code works well for indexing a-z but I need it to work with 0-9 all at once. Does LIKE support regex style abbreviations like I have shown above, or will I have to resort to something like:

Code: Select all

SELECT * FROM table WHERE LIKE '0%'
Thanks :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If you're using MySQL there is the REGEXP statement....
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Sweet. Worked like a charm. Thanks man. :)
Post Reply