- MySQL 5.1 Reference Manual :: 11 Functions and Operators
-
- MySQL 5.1 Reference Manual
- Preface, Notes, Licenses
- 1 General Information
- 2 Installing and Upgrading MySQL
- 3 Tutorial
- 4 MySQL Programs
- 5 MySQL Server Administration
- 6 Backup and Recovery
- 7 Optimization
- 8 Language Structure
- 9 Internationalization and Localization
- 10 Data Types
- 11 Functions and Operators
- 12 SQL Statement Syntax
- 13 Storage Engines
- 14 High Availability and Scalability
- 15 MySQL Enterprise Monitor
- 16 Replication
- 17 MySQL Cluster NDB 6.X/7.X
- 18 Partitioning
- 19 Stored Programs and Views
- 20 INFORMATION_SCHEMA Tables
- 21 Connectors and APIs
- 22 Extending MySQL
- A MySQL 5.1 Frequently Asked Questions
- B Errors, Error Codes, and Common Problems
- C MySQL Change History
- D Restrictions and Limits
- Index
- Standard Index
- C Function Index
- Command Index
- Function Index
- INFORMATION_SCHEMA Index
- Transaction Isolation Level Index
- JOIN Types Index
- Operator Index
- Option Index
- Privileges Index
- SQL Modes Index
- Status Variable Index
- Statement/Syntax Index
- System Variable Index
Table of Contents [+/-]
- 11.1. Operator and Function Reference
- 11.2. Operators [+/-]
- 11.3. Control Flow Functions
- 11.4. String Functions [+/-]
- 11.5. Numeric Functions [+/-]
- 11.6. Date and Time Functions
- 11.7. What Calendar Is Used By MySQL?
- 11.8. Full-Text Search Functions [+/-]
- 11.9. Cast Functions and Operators
- 11.10. XML Functions
- 11.11. Other Functions [+/-]
-
11.12. Functions and Modifiers for Use with
GROUP BY
Clauses [+/-] - 11.13. Spatial Extensions [+/-]
- 11.14. Precision Math [+/-]
Expressions can be used at several points in SQL statements, such as in the
ORDER BY
orHAVING
clauses ofSELECT
statements, in theWHERE
clause of aSELECT
,DELETE
, orUPDATE
statement, or inSET
statements. Expressions can be written using literal values, column values,NULL
, built-in functions, stored functions, user-defined functions, and operators. This chapter describes the functions and operators that are allowed for writing expressions in MySQL. Instructions for writing stored functions and user-defined functions are given in Section 19.2, “Using Stored Routines (Procedures and Functions)”, and Section 22.3, “Adding New Functions to MySQL”. See Section 8.2.4, “Function Name Parsing and Resolution”, for the rules describing how the server interprets references to different kinds of functions.An expression that contains
NULL
always produces aNULL
value unless otherwise indicated in the documentation for a particular function or operator.Note
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.
You can tell the MySQL server to accept spaces after function names by starting it with the
--sql-mode=IGNORE_SPACE
option. (See Section 5.1.7, “Server SQL Modes”.) Individual client programs can request this behavior by using theCLIENT_IGNORE_SPACE
option formysql_real_connect()
. In either case, all function names become reserved words.For the sake of brevity, most 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