MySQL Substring not Returning Anything + Solution
Aug 20, 2013 · 1 minute readCategory: mysql
If you are puzzled why your simple usage of the MySQL SUBSTRING() function is not returning anything this could be your solution.
The substring function allows you to specify a string (eg a column), the start character and the length. If you are used to languages like PHP then you are probably used to this kind of function regarding 0 as the starting character. In fact this function regards 1 as the starting character. If you specify 0 then you simply won’t get any results.
This does not work:
SELECT SUBSTRING(column, 0, 10) as tenchars
This does work:
SELECT SUBSTRING(column, 1, 10) as tenchars