MySQL String Functions Part-4

LCASE Function:- LCASE Function is used to convert strings in lowercase. LOWER() and LCASE() both perform the same task. We can say LCASE() is a synonym of LOWER().

Syntax:- LCASE(string)

For Example:-


Output:- mysql is a rdms

LEFT Function:- LEFT Function use to extract the specified number of characters of string from the left side of the given string. It uses two arguments first one is a string and the second one is an integer which denotes the number of character lengths.

Syntax:- LEFT(string, number of chars length)

For Example:-

SELECT LEFT(“MySQL example”, 4)

Output:- MySQL

SELECT LEFT(2468, 2)

Output:- 24

LENGTH Function:- The LENGTH Function is used to find the length of the string. It returns the string length in bytes.

Syntax:- LENGTH(string)

For Example:-

SELECT LENGTH(“kshtutor”);

Output:- 8

 LOCATE Function:- LOCATE Function is used for the first occurrence position of a substring from a given string. From the original string, if the substring will not found then it will return zero. It performs a case-insensitive search. It uses three arguments.

  1. Search string(Required)
  2. Substring for search(Required) i.e. string to be searched
  3. Position (optional). If the position is not mentioned then searching will start from the beginning.

Syntax:- LOCATE(substring, string, Position)

SELECT LOCATE(“o”, “kshtutor.com”);

output:- 7

SELECT LOCATE(“co”, “kshtutor.com”)

output:- 10

SELECT LOCATE(“o”, “kshtutor.com”, 8)


LOWER Function:- The LOWER Function is used to convert a string into lowercase. It is the same as per LCASE() function.

LPAD Function:- LPAD Function uses to add a string left side of the original string.

Syntax:- LPAD(original string, length, lpad string)

For Example:-

SELECT LPAD(“ksh Tutor”, 15, “srkp”);

Output:-srkpsrksh Tutor

LTRIM Function:- LTRIM Function is used to remove leading space from a string.

Syntax:- LTRIM(string)

For Example:-


Output:- KSHTUTOR MySQL Blog

MAKE_SET Function:- MAKE_SET function is used to convert the decimal number in a bit too binary and return the set value with a comma separator.

Syntax:- MAKE_SET(Bit value, string1, string2, string3,…)

For Example:-

Select MAKE_SET(1|2|3, ‘KSH’,’tutor’,’.com’);


Select MAKE_SET(1|2|4, ‘KSH’,’tutor’,’.com’);


Share with:

Leave a Reply

Connect with: