SELECT * FROM dbname WHERE text = 'a%'
(this can get all the `text` fields which begin with the letter "a".)
But how to get the fields where the first letter !=[a-z]?
for example:
\"hello\" // this first letter begin as \ not range in a-z
いけ // also first letter not begin range in a-z
...
may also have a white space as the first character.
So how can you use php mysql query to get all these kinds of results where the first letter !=[a-z]
?
Try this:
SELECT * FROM dbname WHERE text REGEXP '^[^a-zA-Z]';
That is if you want it to be case insensitive (uppercase or lowercase). If you want to allow uppercase letters A-Z then just use:
SELECT * FROM dbname WHERE text REGEXP '^[^a-z]';
Essentially the regular expression says match any string that doesn't have letters a-z at the beginning of the string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With