April 18, 2021

WeAnswer

The complete guide to the beginners as well as to the experienced Web Developers

MySQL String Functions

MySQL has many built-in functions. MySQL String Functions reference contains the string, numeric, date, and advanced functions in MySQL.

1. ASCII

Returns the number code that represents the first character.

Result:

FirstName NumCodeOfFirstChar
123456 49
admin 97
aakash 97
jagdish 106
Ashish 65
Vishal 86

2. CHAR_LENGTH

Returns the length of the string

Result:

StringLength
17

3. CHARACTER_LENGTH

Returns the length of the string

Result:

StringLength
17

4. CONCAT

Join two or more string together

Result:

Str
WeAnswer.xyz

5. CONCAT_WS

Join two or more string together and adds a separator between them

Result:

Str
We*Answer*xyz

6. FIND_IN_SET

return position in a list.

7. FIND_IN_SET

return position a string in a string list.

8. FORMAT

Format the number as a format of “*,***.**”

 

9. INSERT

Replace the string with characters:

 

10. INSTR

Return substring position

 

11. LCASE

Convert to lower case

12. LEFT

Returns sub string from left

13. LENGTH

Returns Length of string

14. LOCATE

Returns the position of the first occurrence of a substring in a string

 

15. LOWER

Convert to lower case as per LCASE

16. LPAD

Returns a string that is left-padded with a specified string to a certain length

17. LTRIM

Returns a string that is left- trim

18. MID

Returns a string that is position start with and specific position

 

19. POSITION

Returns the position of the first occurrence of a substring in a string as per LOCATE

20. REPEAT

Returns a string that repeat number of times

 

21. REPLACE

Returns a string that replace by substring

22. REVERSE

Returns a string that reverse by a string

 

23. RIGHT

Returns sub string from right

 

24. RIGHT

Returns a string that is left-padded with a specified string to a certain length

 

25. RTRIM

Returns a string that is right- trim

26. SPACE

returns a string with a specified number of spaces.

 

27. STRCMP

returns a string compression is true or not.

 

28. SUBSTR

Returns a string that is position start with and specific position as per MID

29. SUBSTRING

Returns a string that is position start with and specific position as per MID

30. SUBSTRING_INDEX

returns a string compression is true or not.

 

31. SUBSTRING_INDEX

returns a string compression is true or not.

 

32. TRIM

returns a trim string.

33. UCASE

Converts a string to upper-case

34. UPPER

Converts a string to upper-case as per UCASE