Chapter 14 函数和运算符
Table of Contents
- 14.1 内置函数和运算符参考
- 14.2 可加载函数参考
- 14.3 表达式求值中的类型转换
- 14.4 运算符
- 14.5 流程控制函数
- 14.6 Numeric 函数和运算符
- 14.7 日期和时间函数
- 14.8 String 函数和运算符
- 14.9 全文搜索函数
- 14.10 Cast 函数和运算符
- 14.11 XML 函数
- 14.12 Bit 函数和运算符
- 14.13 加密和压缩函数
- 14.14 锁定函数
- 14.15 信息函数
- 14.16 空间分析函数
- 14.17 JSON 函数
- 14.18 复制函数
- 14.19 聚合函数
- 14.20 窗口函数
- 14.21 性能模式函数
- 14.22 内部函数
- 14.23 杂项函数
- 14.24 精确数学
Expressions can be used at several points in SQL statements, such as in the ORDER BY
or HAVING
clauses of SELECT
statements, in the WHERE
clause of a SELECT
, DELETE
, or UPDATE
statement, or in SET
statements. Expressions can be written using values from several sources, such as literal values, column values, NULL
, variables, built-in functions and operators, loadable functions, and stored functions (a type of stored object).
This chapter describes the built-in functions and operators that are permitted for writing expressions in MySQL. For information about loadable functions and stored functions, see Section 7.7, “MySQL Server Loadable Functions”, and Section 27.2, “Using Stored Routines”. For the rules describing how the server interprets references to different kinds of functions, see Section 11.2.5, “Function Name Parsing and Resolution”.
An expression that contains NULL
always produces a NULL
value unless otherwise indicated in the documentation for a particular function or operator.
By default, there must be no whitespace between a function name and the parenthesis following it. This helps the MySQL parser distinguish between function calls and references to tables or columns that happen to have the same name as a function. However, spaces around function arguments are permitted.
To tell the MySQL server to accept spaces after function names by starting it with the --sql-mode=IGNORE_SPACE
option. (See Section 7.1.11, “Server SQL Modes”.) Individual client programs can request this behavior by using the CLIENT_IGNORE_SPACE
option for mysql_real_connect()
. In either case, all function names become reserved words.
For the sake of brevity, some examples in this chapter display the output from the mysql program in abbreviated form. Rather than showing examples in this format:
mysql> SELECT MOD(29,9);
+-----------+
| mod(29,9) |
+-----------+
| 2 |
+-----------+
1 rows in set (0.00 sec)
This format is used instead:
mysql> SELECT MOD(29,9);
-> 2