SQL Substring Not Start From 0

If you are database administrator or a back-end software developer, and you just not having enough experience in SQL Queries other than selecting, updating, insert drop, you may get frustrated about this select SUBSTRING  thing in MySQL.

Yes MySQL have a SUBSTRING function, it is really confusing because its start parameter is from 1 not from 0. I've been doing this so many times, but still can not understand why i wasting so many times by this function.

The right syntax for function SUBSTRING in SQL is:

SUBSTRING(colomn_name, start, lenght)

So for example if i have data without filtering like this. Then when i run this query:
SELECT no, random FROM my_table LIMIT 15;


Then i select random using substring:
SELECT no, SUBSTRING(random, 1, 3) FROM my_table LIMIT 15;


Substring in MySQL is confusing, not like any programming language which usualy start from 0, it is start from 1.


Comments

Popular posts from this blog

Flixify Video Streaming Platform

ERROR 1348 Column Password Is Not Updatable When Updating MySQL Root Password

Push Notification Cordova, FCM And PHP