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

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

ASUS Battery Health Charging Software To Make Your Battery Life Longer

Is Nox Player a Malware? Nox Android Emulator

How To Uninstall Angular CLI, The Angular Framework

How To Create Spring Boot Project Using Netbeans

JavaFX Combo Box with Search Autocomplete

Push Notification Cordova, FCM And PHP

How to Add MySQL JDBC Driver To Wildfly

JavaFX Dialog Material Design

JavaFX Email Validation using JFoenix TextField