A common request is how to select records from a table when a specific field starts with a number. This request often is used when searching free-form text fields where the fields were used to provide an answer field to a question.
The simplest way to attack this is by using a regular expression. For example:
SELECT * FROM BadlyDesignedTable WHERE AnswerColumn regexp ‘^[0-9]+’;
SELECT * FROM BadlyDesignedTable WHERE AnswerColumn RLIKE ‘^[0-9]+’;
Regex and RLIKE are compatible keywords that both represent regular expression matching.
The regex is described as follows :
- Topgun Days by Dave “Bio” Baranek – The Truth Behind Topgun and Top Gun
- MySQL – A simple script to truncate all MySQL tables in a Database