12.8 String Functions and Operators字符串函数和运算符

12.8.1 String Comparison Functions and Operators字符串比较函数和运算符
12.8.2 Regular Expressions正则表达式
12.8.3 Character Set and Collation of Function Results字符集与函数结果的排序

Table 12.12 String Functions and Operators字符串函数和运算符

Name名称Description描述
ASCII()Return numeric value of left-most character返回最左边字符的数值
BIN()Return a string containing binary representation of a number返回包含数字二进制表示形式的字符串
BIT_LENGTH()Return length of argument in bits返回以位为单位的参数长度
CHAR()Return the character for each integer passed返回传递的每个整数的字符
CHAR_LENGTH()Return number of characters in argument返回参数中的字符数
CHARACTER_LENGTH()Synonym for CHAR_LENGTH()CHAR_LENGTH()的同义词
CONCAT()Return concatenated string返回串联字符串
CONCAT_WS()Return concatenate with separator返回带分隔符的串联
ELT()Return string at index number返回索引号处的字符串
EXPORT_SET()Return a string such that for every bit set in the value bits, you get an on string and for every unset bit, you get an off string返回一个字符串,这样对于在值位中设置的每一位,您得到一个on字符串,对于每一个未设置的位,您得到一个off字符串
FIELD()Index (position) of first argument in subsequent arguments后继参数中第一个参数的索引(位置)
FIND_IN_SET()Index (position) of first argument within second argument第一个参数在第二个参数中的索引(位置)
FORMAT()Return a number formatted to specified number of decimal places返回格式化为指定小数位数的数字
FROM_BASE64()Decode base64 encoded string and return result解码base64编码字符串并返回结果
HEX()Hexadecimal representation of decimal or string value十进制或字符串值的十六进制表示法
INSERT()Insert substring at specified position up to specified number of characters在指定位置插入子字符串,最多可插入指定的字符数
INSTR()Return the index of the first occurrence of substring返回子字符串第一次出现的索引
LCASE()Synonym for LOWER()LOWER()的同义词
LEFT()Return the leftmost number of characters as specified返回指定的最左边的字符数
LENGTH()Return the length of a string in bytes返回字符串的字节长度
LIKESimple pattern matching简单模式匹配
LOAD_FILE()Load the named file加载命名文件
LOCATE()Return the position of the first occurrence of substring返回子字符串第一次出现的位置
LOWER()Return the argument in lowercase以小写形式返回参数
LPAD()Return the string argument, left-padded with the specified string返回字符串参数,左填充指定的字符串
LTRIM()Remove leading spaces删除前导空格
MAKE_SET()Return a set of comma-separated strings that have the corresponding bit in bits set返回一组以逗号分隔的字符串,这些字符串的位集中有相应的位
MATCHPerform full-text search执行全文搜索
MID()Return a substring starting from the specified position返回从指定位置开始的子字符串
NOT LIKENegation of simple pattern matching简单模式匹配的否定
NOT REGEXPNegation of REGEXPREGEXP的否定
OCT()Return a string containing octal representation of a number返回包含数字八进制表示的字符串
OCTET_LENGTH()Synonym for LENGTH()LENGTH()的同义词
ORD()Return character code for leftmost character of the argument返回参数最左边字符的字符代码
POSITION()Synonym for LOCATE()LOCATE()的同义词
QUOTE()Escape the argument for use in an SQL statement转义参数以在SQL语句中使用
REGEXPWhether string matches regular expression字符串是否匹配正则表达式
REGEXP_INSTR()Starting index of substring matching regular expression子串匹配正则表达式的起始索引
REGEXP_LIKE()Whether string matches regular expression字符串是否匹配正则表达式
REGEXP_REPLACE()Replace substrings matching regular expression替换与正则表达式匹配的子字符串
REGEXP_SUBSTR()Return substring matching regular expression返回子字符串匹配正则表达式
REPEAT()Repeat a string the specified number of times重复指定次数的字符串
REPLACE()Replace occurrences of a specified string替换指定字符串的出现
REVERSE()Reverse the characters in a string反转字符串中的字符
RIGHT()Return the specified rightmost number of characters返回指定的最右边的字符数
RLIKEWhether string matches regular expression字符串是否匹配正则表达式
RPAD()Append string the specified number of times追加指定次数的字符串
RTRIM()Remove trailing spaces删除尾随空格
SOUNDEX()Return a soundex string返回soundex字符串
SOUNDS LIKECompare sounds比较声音
SPACE()Return a string of the specified number of spaces返回指定空格数的字符串
STRCMP()Compare two strings比较两个字符串
SUBSTR()Return the substring as specified按指定返回子字符串
SUBSTRING()Return the substring as specified按指定返回子字符串
SUBSTRING_INDEX()Return a substring from a string before the specified number of occurrences of the delimiter从指定的分隔符出现次数之前的字符串返回子字符串
TO_BASE64()Return the argument converted to a base-64 string返回转换为base-64字符串的参数
TRIM()Remove leading and trailing spaces删除前导空格和尾随空格
UCASE()Synonym for UPPER()UPPER()的同义词
UNHEX()Return a string containing hex representation of a number返回包含数字十六进制表示形式的字符串
UPPER()Convert to uppercase转换为大写
WEIGHT_STRING()Return the weight string for a string返回字符串的权重字符串

String-valued functions return NULL if the length of the result would be greater than the value of the max_allowed_packet system variable. 如果结果的长度大于max_allowed_packet系统变量的值,则字符串值函数返回NULLSee Section 5.1.1, “Configuring the Server”.请参阅第5.1.1节“配置服务器”

For functions that operate on string positions, the first position is numbered 1.对于操作字符串位置的函数,第一个位置编号为1。

For functions that take length arguments, noninteger arguments are rounded to the nearest integer.对于采用长度参数的函数,非整数参数将舍入到最接近的整数。

12.8.1 String Comparison Functions and Operators
12.8.2 Regular Expressions
12.8.3 Character Set and Collation of Function Results