Here's my mySQL query:
SELECT * FROM `eodList` WHERE datechanged>='$curdate' GROUP BY symbolName ORDER BY dateChanged DESC
How do you get all rows (for instance) where
symbolName begins with letters
I want something that may be easily transformed to a different range without a lot of code changes.
Try with Regex
WHERE symbolName REGEXP '^[A-F]'
SELECT * FROM `eodList` WHERE datechanged>='$curdate' AND ((SUBSTRING(symbolName, 1, 1) >= "A" AND SUBSTRING(symbolName, 1, 1) <="F")) GROUP BY symbolName ORDER BY dateChanged DESC
Regular expressions and
SUBSTRING() function calls. This can make use of the index of
WHERE symbolName >= 'A' AND symbolName < 'G'
There's an problem using the situation sensitivity though. Would you like names which begin with
a..f too or otherwise?
If you would like only names that begin with uppercase and also the table has
utf8 character set, use:
WHERE symbolName >= 'A' COLLATE utf8_bin AND symbolName < 'G' COLLATE utf8_bin
For other character sets, make use of the corresponding