I saw some confusing answers here that I tried, but were simply erroneous (did not work) or unsafe (replaced each occurrence of "the"). A decision that I think is easy, or maybe I'm wrong or don't consider extreme cases (sincerely, without sarcasm).
... ORDER BY SUBSTRING(UPPER(fieldname), IF(fieldname LIKE 'The %', 5, 1))
As indicated elsewhere, UPPER simply prevents ASCII sorting, which orders B to a (note the difference in case).
There is no need for a switch-case , when there is only one condition, IF() will execute
I am using MySQL 5.6 and it seems that the string functions are 1-indexed, unlike PHP, where the rows are indexed 0 (this caught me). I tested above on my dataset and it works
Luke madhanga
source share