String Functions

MySQL string functions can be used to change the value of columns containing strings of alphanumeric values.

ASCII( )

This MySQL function returns the numeric code corresponding to the first character of a given string.

BIN( )

This MySQL function returns a binary number for a given integer.

BINARY

Use this MySQL function to treat strings in their binary state.

BIT_LENGTH( )

This MySQL function returns the number of bits in a given string.

CAST( )

Use this MySQL function to convert a value from one datatype to another.

CHAR( )

This MySQL function returns a string corresponding to the numeric code passed as the argument.

CHARACTER_LENGTH( )

This MySQL function returns the number of characters of a given string.

CHARSET( )

This MySQL function returns the character set used by a given string.

CHAR_LENGTH( )

This MySQL function returns the number of characters in a given string.

COALESCE( )

This MySQL function returns the leftmost non-NULL string or column in a comma-separated list.

COERCIBILITY( )

This MySQL function returns an arbirary value known as the coercibility of a given string or other item, determning how likely that item is to determine the collation used in an expression.

COLLATION( )

This MySQL function returns the collation for the character set of a given string.

COMPRESS( )

This MySQL function returns a given string after compressing it.

With this MySQL function, strings or columns can be concatenated or pasted together into one resulting field.

CONVERT( )

Use this MySQL function to convert the character set of a given string to another character set specified with the USING keyword.

CRC32( )

This MySQL function returns the given string's cyclic redundancy check value as a 32-bit unsigned value.

ELT( )

This MySQL function returns the index element from the list of strings given, where the list is numbered starting with 1.

EXPORT_SET( )

This MySQL function returns a series of strings in order that represent each bit of a given number.

FIELD( )

This MySQL function searches for the first string given in the following list of strings and returns the numeric position of the first string in the list that matches.

FIND_IN_SET( )

This MySQL function returns the location of the first argument within a comma-separated list that is passed as a single stringin the second argument.

HEX( )

The first version of this MySQL function accepts a string and returns its numerical value, in hexadecimal, as it is represented in the underlying character set.

INSERT( )

This MySQL function inserts the string from the final argument into the string specified by the first argument, at the specified position.

INSTR( )

This MySQL function returns the starting position of the first occurrence of the substring in the string given as the first argument.

INTERVAL( )

This MySQL function returns the position where search_value would be located in a comma-separated list of ordered_value arguments.

This MySQL function converts a string given to all lowercase letters.

This MySQL function returns the first length characters from a string.

LENGTH( )

This MySQL function returns the number of bytes contained in a given string.

LOAD_FILE( )

This MySQL function reads the contents of a file and returns it as a string that may be used in MySQL statements and functions.

This MySQL function returns the numeric starting point of the first occurrence of a substring in the string supplied as a second argument.

LOWER( )

This MySQL function converts a string given to all lowercase letters.

LPAD( )

This MySQL function adds padding to the left end of string, stopping if the combination of string and the added padding reach length characters.

LTRIM( )

This MySQL function returns the given string with any leading spaces removed.

MAKE_SET( )

This MySQL function converts the decimal number in bits to binary and returns a comma-separated list of values for all the bits that are set in that number, using string1 for the low-order bit, string2 for the next lowest bit, etc.

MATCH ( ) AGAINST( )

This MySQL function is used only for columns indexed by a FULLTEXT index, and only in WHERE clauses.

MID( )

This MySQL function returns the characters of a given string, starting from the position specified in the second argument.

OCTET_LENGTH( )

This MySQL function returns the number of bytes contained in the given string.

ORD( )

This MySQL function returns an ordinal value, the position of a character in the ASCII character set of the left-most character in a given string.

POSITION( )

This MySQL function returns index of the character in string where substring first appears.

quote( )

This MySQL function accepts a string enclosed in single quotes and returns a string that is safe to manipulate with SQL statements.

QUOTE( )

This MySQL function accepts a string enclosed in single quotes and returns a string that is safe to manipulate with SQL statements.

REPEAT( )

This MySQL function returns the string given in the first argument of the function, as many times as specified in the second argument.

REPLACE( )

This MySQL function goes through the first argument and returns a string in which every occurrence of the second argument is replaced with third argument.

REVERSE( )

This MySQL function returns the characters of string in reverse order.

RIGHT( )

This MySQL function returns the final length characters from a string.

This MySQL function adds padding to the right end of string, stopping if the combination of string and the added padding reach length characters.

RTRIM( )

This MySQL function returns the given string with any trailing spaces removed.

SOUNDEX( )

This MySQL function returns the results of a classic algorithm that can be used to compare two similar strings.

SPACE( )

This MySQL function returns a string of spaces.

STRCMP( )

This MySQL function compares two strings to determine whether the first string is before or after the second string in ASCII sequence.

SUBSTR( )

This MySQL function is an alias of SUBSTRING().

This MySQL function returns the characters of a given string, starting from the position given.

SUBSTRING_INDEX( )

This MySQL function returns a substring of string, using delimiter to separate substrings and count to determine which of the substrings to return.

TRIM( )

This MySQL function returns the given string with any trailing or leading padding removed, depending on which is specified.

UCASE( )

This MySQL function converts a string given to all uppercase letters.

UNCOMPRESS( )

This MySQL function returns the uncompressed string corresponding to the compressed string given, reversing the results of the COMPRESS( ) function.

UNCOMPRESSED_LENGTH( )

This MySQL function returns the number of characters contained in the given compressed string before it was compressed.

UNHEX( )

This MySQL function converts hexadecimal numbers to their character equivalents.

UPPER( )

This MySQL function converts a given string to all uppercase letters.