http://dev.mysql.com/doc/refman/5.0/en/expressions.html
http://dev.mysql.com/doc/refman/5.0/en/functions.html
Chapter 12. Functions and Operators
Table of Contents [+/-]
- 12.1. Function and Operator Reference
- 12.2. Type Conversion in Expression Evaluation
- 12.3. Operators [+/-]
- 12.4. Control Flow Functions
- 12.5. String Functions [+/-]
- 12.6. Numeric Functions and Operators [+/-]
- 12.7. Date and Time Functions
- 12.8. What Calendar Is Used By MySQL?
- 12.9. Full-Text Search Functions [+/-]
- 12.10. Cast Functions and Operators
- 12.11. Bit Functions
- 12.12. Encryption and Compression Functions
- 12.13. Information Functions
- 12.14. Miscellaneous Functions
- 12.15. Functions and Modifiers for Use with
GROUP BYClauses [+/-] - 12.16. Spatial Extensions [+/-]
- 12.17. Precision Math [+/-]
Expressions can be used at several points in SQL statements, such as in the
ORDER BY or HAVING clauses of SELECTstatements, in the WHERE clause of a SELECT, DELETE, orUPDATE statement, or in SET 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 permitted for writing expressions in MySQL. Instructions for writing stored functions and user-defined functions are given in Section 18.2, “Using Stored Routines (Procedures and Functions)”, and Section 21.2, “Adding New Functions to MySQL”. See Section 9.2.3, “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 a NULLvalue 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.
EXPRESSIONS SYNTAX:
expr:exprORexpr|expr||expr|exprXORexpr|exprANDexpr|expr&&expr| NOTexpr| !expr|boolean_primaryIS [NOT] {TRUE | FALSE | UNKNOWN} |boolean_primaryboolean_primary:boolean_primaryIS [NOT] NULL |boolean_primary<=>predicate|boolean_primarycomparison_operatorpredicate|boolean_primarycomparison_operator{ALL | ANY} (subquery) |predicatecomparison_operator: = | >= | > | <= | < | <> | !=predicate:bit_expr[NOT] IN (subquery) |bit_expr[NOT] IN (expr[,expr] ...) |bit_expr[NOT] BETWEENbit_exprANDpredicate|bit_exprSOUNDS LIKEbit_expr|bit_expr[NOT] LIKEsimple_expr[ESCAPEsimple_expr] |bit_expr[NOT] REGEXPbit_expr|bit_exprbit_expr:bit_expr|bit_expr|bit_expr&bit_expr|bit_expr<<bit_expr|bit_expr>>bit_expr|bit_expr+bit_expr|bit_expr-bit_expr|bit_expr*bit_expr|bit_expr/bit_expr|bit_exprDIVbit_expr|bit_exprMODbit_expr|bit_expr%bit_expr|bit_expr^bit_expr|bit_expr+interval_expr|bit_expr-interval_expr|simple_exprsimple_expr:literal|identifier|function_call|simple_exprCOLLATEcollation_name|param_marker|variable|simple_expr||simple_expr| +simple_expr| -simple_expr| ~simple_expr| !simple_expr| BINARYsimple_expr| (expr[,expr] ...) | ROW (expr,expr[,expr] ...) | (subquery) | EXISTS (subquery) | {identifierexpr} |match_expr|case_expr|interval_expr
Notes:
For literal value syntax, see Section 9.1, “Literal Values”.
For identifier syntax, see Section 9.2, “Schema Object Names”.
Variables can be user variables, system variables, or stored program local variables or parameters:
- User variables: Section 9.4, “User-Defined Variables”
- System variables: Section 5.1.5, “Using System Variables”
- Local variables: Section 13.6.4.1, “Local Variable
DECLARESyntax”
param_marker is '?' as used in prepared statements for placeholders. See Section 13.5.1, “PREPARESyntax”.(subquery) indicates a subquery that returns a single value; that is, a scalar subquery. SeeSection 13.2.9.1, “The Subquery as Scalar Operand”.{identifier expr} is ODBC escape syntax and is accepted for ODBC compatibility. The value isexpr. The curly braces in the syntax should be written literally; they are not metasyntax as used elsewhere in syntax descriptions.interval_expr represents a time interval. The syntax is INTERVAL expr unit, where unit is a specifier such as HOUR, DAY, or WEEK. For the full list of unit specifiers, see the description of theDATE_ADD() function in Section 12.7, “Date and Time Functions”.
The meaning of some operators depends on the SQL mode:
- By default,
||is a logicalORoperator. WithPIPES_AS_CONCATenabled,||is string concatenation, with a precedence between^and the unary operators. - By default,
!has a higher precedence thanNOTas of MySQL 5.0.2. For earlier versions, or from 5.0.2 on withHIGH_NOT_PRECEDENCEenabled,!andNOThave the same precedence.
No comments:
Post a Comment