Skip to content
Related Articles

Related Articles

Improve Article

LCASE Function, LEFT Function and LOCATE Function in MariaDB

  • Last Updated : 16 Dec, 2020

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 :

  • String – The string which will be convert in lower case.

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 :



  • String – String which left character need to find.
  • Number_of_characters – Total number of character from the start of the string.

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 :

  • Substring – Substring which will be search in the the given string.
  • String – String in which search of the substring will be performed.
  • Start_position – Starting position of the string from which substring will be searched.

    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

    Attention reader! Don’t stop learning now. Learn SQL for interviews using SQL Course  by GeeksforGeeks.

    My Personal Notes arrow_drop_up
  • Recommended Articles
    Page :