mysql - Fetch rows where first character is not alphanumeric -
I'm adding some new features to a small project, on which I am working and one of these alpha endorsements It looks like
# 0- 9 ABCDE ... XYZ
I can easily get anything from my first letter through a few things
SELECT * FROM ... where 'A%' ... like the name starts with a number and all other characters Grouping anything else a little bit More difficult, I think it would be using MySQLs REGEXP.
Just to be clear, I need help in making two questions which will get all the rows where
- the first letter in the column is numeric
- The first letter in the column is not alphanumeric
The first letter is numeric:
SELECT ... FROM ... WHERE name REGEXP '^ [0-9]';
The first letter is not alphanumeric:
SELECT ... FROM ... WHERE name REGEXP '^ [^ 0- 9A-Za-z]';
(Note that this is different from NOT REGEXP ^ [0-9A-Za-z]
, because you only < / P>
You may choose the option of [^ [alnum:]] option for [code]. [^ 0- 9a-za-z]
, but I have not tested it. You can definitely option [[digits:]]
for [0-9]
But it is longer: -)
Also see.
Comments
Post a Comment