String
You can find definitions of string functions from ascii to upper:
Function | Description |
---|---|
ascii | Returns the numeric value of the leftmost character of the string str. Returns 0 if str is the empty string. Returns NULL if str is NULL. ASCII() works for characters with numeric values from 0 to 255. |
bin | Returns a string representation of the binary value of N, where N is a longlong (BIGINT) number. This is equivalent to CONV(N,10,2). Returns NULL if N is NULL. |
bit_length | Returns the length of the string str in bits. |
Char | CHAR() interprets each argument N as an integer and returns a string consisting of the characters given by the code values of those integers. NULL values are skipped. |
char_length | Returns the length of the string str, measured in characters. A multi-byte character counts as a single character. This means that for a string containing five two-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5. |
character_length | CHARACTER_LENGTH() is a synonym for CHAR_LENGTH(). |
concat | Returns the string that results from concatenating the arguments. |
concat_ws | CONCAT_WS() stands for Concatenate With Separator and is a special form of CONCAT(). The first argument is the separator for the rest of the arguments. The separator is added between the strings to be concatenated. The separator can be a string, as can the rest of the arguments. If the separator is NULL, the result is NULL. |
conv | Converts numbers between different number bases. Returns a string representation of the number N, converted from base from_base to base to_base. Returns NULL if any argument is NULL. The argument N is interpreted as an integer, but may be specified as an integer or a string. The minimum base is 2 and the maximum base is 36. If to_base is a negative number, N is regarded as a signed number. Otherwise, N is treated as unsigned. CONV() works with 64-bit precision. |
elt | Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().' |
export_set | Returns a string such that for every bit set in the value bits, you get an on string and for every reset bit, you get an off string. Bits in bits are examined from right to left (from low-order to high-order bits). Strings are added to the result from left to right, separated by the separator string (the default being the comma character). The number of bits examined is given by number_of_bits (defaults to 64). |
field | Returns the index (position) of str in the str1, str2, str3, ... list. Returns 0 if str is not found. |
field_in_set | Returns a value in the range of 1 to N if the string str is in the string list strlist consisting of N substrings. A string list is a string composed of substrings separated by comma characters. If the first argument is a constant string and the second is a column of type SET, the FIND_IN_SET() function is optimized to use bit arithmetic. Returns 0 if str is not in strlist or if strlist is the empty string. Returns NULL if either argument is NULL. This function does not work properly if the first argument contains a comma character. |
format | Formats the number X to a format like “#,###,###.##”, rounded to D decimal places, and returns the result as a string. If D is 0, the result has no decimal point or fractional part. |
hex | If N_or_S is a number, returns a string representation of the hexadecimal value of N, where N is a longlong (BIGINT) number. This is equivalent to CONV(N,10,16). If N_or_S is a string, returns a hexadecimal string representation of N_or_S where each character in N_or_S is converted to two hexadecimal digits. |
insert | Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr. Returns the original string if pos is not within the length of the string. Replaces the rest of the string from position pos is len is not within the length of the rest of the string. Returns NULL if any argument is NULL. |
instr | Returns the position of the first occurrence of substring substr in string str. This is the same as the two-argument form of LOCATE(), except that the order of the arguments is reversed. |
lcase | LCASE() is a synonym for LOWER(). |
left | Returns the leftmost len characters from the string str, or NULL if any argument is NULL. |
length | Returns the length of the string str, measured in bytes. A multi-byte character counts as multiple bytes. This means that for a string containing five two-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5. |
locate | The first syntax returns the position of the first occurrence of substring substr in string str. The second syntax returns the position of the first occurrence of substring substr in string str, starting at position pos. Returns 0 if substr is not in str. |
lower | Returns the string str with all characters changed to lowercase according to the current character set mapping. The default is latin1 (cp1252 West European). |
lpad | Returns the string str, left-padded with the string padstr to a length of len characters. If str is longer than len, the return value is shortened to len characters. |
ltrim | Returns the string str with leading space characters removed. |
mid | MID(str,pos,len) is a synonym for SUBSTRING(str,pos,len). |
oct | Returns a string representation of the octal value of N, where N is a longlong (BIGINT) number. This is equivalent to CONV(N,10,8). Returns NULL if N is NULL. |
octet_length | OCTET_LENGTH() is a synonym for LENGTH(). |
ord | If the leftmost character of the string str is a multi-byte character, returns the code for that character. The leftmost character is not a multi-byte character, ORD() returns the same value as the ASCII() function. |
quote | Quotes a string to produce a result that can be used as a properly escaped data value in an SQL statement. The string is returned enclosed by single quotes and with each instance of single quote, backslash, ASCII NUL, and Control-Z preceded by a backslash. If the argument is NULL, the return value is the word “NULL” without enclosing single quotes. |
repeat | Returns a string consisting of the string str repeated count times. If count is less than 1, returns an empty string. Returns NULL if str or count are NULL. |
replace | Returns the string str with all occurrences of the string from_str replaced by the string to_str. REPLACE() performs a case-sensitive match when searching for from_str. |
reverse | Returns the string str with the order of the characters reversed. |
right | Returns the rightmost len characters from the string str, or NULL if any argument is NULL. |
rpad | Returns the string str, right-padded with the string padstr to a length of len characters. If str is longer than len, the return value is shortened to len characters. |
rtrim | Returns the string str with trailing space characters removed. |
soundex | Returns a soundex string from str. Two strings that sound almost the same should have identical soundex strings. A standard soundex string is four characters long, but the SOUNDEX() function returns an arbitrarily long string. You can use SUBSTRING() on the result to get a standard soundex string. All non-alphabetic characters in str are ignored. All international alphabetic characters outside the A-Z range are treated as vowels. |
space | Returns a string consisting of N space characters.' |
substring | The forms without a len argument return a substring from string str starting at position pos. The forms with a len argument return a substring len characters long from string str, starting at position pos. The forms that use FROM are standard SQL syntax. It is also possible to use a negative value for pos. In this case, the beginning of the substring is pos characters from the end of the string, rather than the beginning. A negative value may be used for pos in any of the forms of this function. |
substring_index | Returns the substring from string str before count occurrences of the delimiter delim. If count is positive, everything to the left of the final delimiter (counting from the left) is returned. If count is negative, everything to the right of the final delimiter (counting from the right) is returned. SUBSTRING_INDEX() performs a case-sensitive match when searching for delim. |
ucase | UCASE() is a synonym for UPPER(). |
unhex | Performs the inverse operation of HEX(str). That is, it interprets each pair of hexadecimal digits in the argument as a number and converts it to the character represented by the number. The resulting characters are returned as a binary string. |
upper | Returns the string str with all characters changed to uppercase according to the current character set mapping. The default is latin1 (cp1252 West European). |
Parent Topic: Functions