Other String Functions

COERCIBILITY

Gets coercibility for an expression.

ELT

Return string at index number.

EXPORT_SET

Return a string

FORMAT

Return a number formatted to specified number of decimal places.

LOAD_FILE

Load the named file.

LPAD

Return the string argument, left-padded with the specified string.

MAKE_SET

Return a set of comma-separated strings that have the corresponding bit in bits set.

MATCH

Perform full-text search.

MID

Return a substring starting from the specified position.

QUOTE

Escape the argument for use in an SQL statement.

REPEAT

Repeat a string the specified number of times.

REPLACE

The REPLACE() function returns a string with all occurrences of the ‘from_str’ replaced by ‘to_str’. REPLACE is case-sensitive when searching for ‘from_str’.

Syntax:

REPLACE(str,from_str,to_str)

For example:

SELECT REPLACE('www.google.com', 'w', 'v');

Returns: vvv.google.com

REVERSE

This function returns a string argument with the characters in reverse order.

SELECT REVERSE('abcd');

Returns: dcba

RPAD

Append string the specified number of times

SOUNDEX

Return a soundex string

SUBSTR

Synonym for SUBSTRING().

SUBSTRING

Returns the substring as specified

Examples that use SUBSTRING() in the SELECT clause:

The SUBSTRING() function is used to extract a character string (using a given starting position and a given length).

SELECT
SUBSTRING(course_designater,6,3) as 'Course number'
FROM Courses
WHERE course_designater LIKE 'Excel%'
LIMIT 10;

You can also format a column using SUBSTRING() in combination with functions like LOWER() and UPPER().

SELECT
CONCAT(UPPER(SUBSTRING(lastname,1,1)),
LOWER(SUBSTRING(lastname,2,29)))
FROM Students
LIMIT 10;

SUBSTRING_INDEX

Return a substring from a string before the specified number of occurrences of the delimiter.

Table Of Contents

Previous topic

Position Functions

Next topic

Utility Functions

This Page