Open In App

LCASE Function, LEFT Function and LOCATE Function in MariaDB

1. LCASE Function : In MariaDB, the LCASE Function is used for the converting all strings in the lowercase. This function will take string is as a parameter and it will return that strings in the lowercase string. If the string can contain any character which does not letter then that will not be affected by this function. It works like the LOWER() function. This function will convert the characters using the current character mapping set. By default which is latin1. 

Syntax :



LCASE(string) 

Parameters :

Return : It return string which all character in the lower case. 



Example-1 :

SELECT LCASE('Geeksforgeeks');

Output :

geeksforgeeks

Example-2 :

SELECT LCASE('CO_MPU_TER');

Output :

co_mpu_ter

Example-3 :

SELECT LCASE('@ Self @paced');

Output :

@ self @paced

2. LEFT Function : In MariaDB, the LEFT Function is used for the extracting the string from the left of total length which is given. This function will take string is as a parameter and it will return that string the no of characters from left. If the given number exceeds the length of the string then it will return the original string. 

Syntax :

LEFT(string, number_of_characters)

Parameters :

Return : It return the number of character from the left of the string. 

Example-1 :

SELECT LEFT('data', 1);

Output :

d

Example-2 :

SELECT LEFT('Article', 5);

Output :

Artic

Example-3 :

SELECT LEFT('dsa', 108);

Output :

dsa

3. LOCATE Function : In MariaDB, the LOCATE Function is used for finding the first location of the substring in the string. This function will take substring is as a first parameter, and the second parameter will be string, the third parameter will be the starting point. It will return that location of substring first occurrence in the string from the starting position. If the substring is not in the string then it will return 0. It works non-case sensitive operations. 

Syntax :

LOCATE( substring, string, [start_position ] )

Parameters :

Return : It will return the first location of the substring in the string. 

Example-1 :

SELECT LOCATE('n', 'noncase');

Output :

1

Example-2 :

SELECT LOCATE('n', 'banana', 4);

Output :

5

Example-3 :

SELECT LOCATE('new', 'Example');

Output :

0
Article Tags :
SQL