Javatpoint Logo
Javatpoint Logo

MySQL String Function

MySQL string functions manipulate the character string data effectively. The following table indicates each of the functions with a brief description:

Functions Description
CONCAT_WS() MySQL CONCAT_WS() function returns a string by concatenating arguments using separator.
CONCAT() The CONCAT() function returns a string by concatenating all the arguments.
CHARACTER_LENGTH() The CHARACTER_LENGTH() function returns the size of the specified string.
ELT() The ELT() function returns the Nth element from the list of string.
EXPORT_SET() The EXPORT_SET() function the returns string for each bit set.
FIELD() The FIELD() function returns the index of string.
FIND_IN_SET() The FIND_IN_SET() function returns the value of the string which is given in the first position in the argument.
FORMAT() The FORMAT() function formats the number X to round of D decimal place.
FROM_BASE64() The FROM_BASE64() function encodes the given string to binary format.
HEX() The HEX() function returns the specified number or string in a hexadecimal string.
INSERT() In INSERT() function, a string str is passed with a position 'pos' which tells at which position the character is to be placed, and 'len' length is the length of the character to be placed.
INSTR() The INSTR() function returns the 1st occurrence of substring substr in string str.
LCASE() The LCASE() function returns 1st occurrence of substring substr in string str.
LEFT() The LEFT() function returns left side 'len' characters from the given string 'str'.
LENGTH() The LENGTH() function returns the length of the specified string which is measured in bytes.
LIKE() The LIKE() function returns either 1 or 0 and is used for checking pattern matching.
LOAD_FILE() The LOAD_FILE() function returns the content of the file.
LOCATE() The LOCATE() function returns the first occurrence of given 'substr' in the given string.
LOWER() The LOWER() function returns the given string in lower case.
LPAD() The LPAD() function returns string 'str' which is left-padded to the given length.
LTRIM() The LTRIM() function returns string by removing leading space.
MAKE_SET() The MAKE_SET() function returns values from the set for the given bit.
MID() The MID() function extracts a substring from a string and returns a string with given length and position.
OCTET_LENGTH() The OCTET_LENGTH() function returns length of given string.
OCT() The OCT() function returns length of given string.
ORD() The ORD() function returns the code for the leftmost character if that character is a multi-byte.
POSITION() The POSITION() function returns the position of the given substring in a string.
QUOTE() The QUOTE() function returns the string which is passed in a single quote.
REPEAT() The REPEAT() function repeats a string for a specified number of times.
REPLACE() The REPLACE() function replaces all the occurrences of a substring within a string.
REVERSE() The REVERSE() function reverses a string supplied as an argument.
RIGHT() The RIGHT() function extracts a specified number of characters from the right side of a string.
RPAD() The MYSQL RPAD() function pads the specified strings from the right.
RTRIM() The MYSQL RTRIM() function removes the trailing spaces from the specified string.
SOUNDEX() The MYSQL SOUNDEX() function returns the soundex string for the specified string.

Example 1


mysql> SELECT SOUNDEX('javatpoint');
| SOUNDEX('javatpoint') |
| W6262                 | 
1 row in set (0.00 sec)

Example 2


mysql> SELECT ORD('mysql'); 
| ORD('mysql') |
|               109 | 
1 row in set (0.00 sec)

Example 3


mysql> SELECT REPEAT('*+*',15); 
| REPEAT('*+*',15)                              |
| *+**+**+**+**+**+**+**+**+**+**+**+**+**+**+* | 
1 row in set (0.03 sec)
Next TopicMySQL String

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA