MySQL Functions
MySQL Functions can be invoked within expressions and return a value in place of the function call when the expression is evaluated.
Syntax
The general syntax for a MySQL Function call includes the function name followed by a parenthesis
optional argument:
function_name(<arg1>[, <arg2>,…,<argn>])
Spaces around function arguments are permitted. However, by default there must be no white-space 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.
Functions in MySQL Expressions
A function call is a value expression, and can thus appear anywhere where a value expression is accepted. Columns are also perfectly fine to use as arguments as long as they are in the correct data type. A function’s output can also be the input to another MySQL function.
An expression that contains NULL always produces a NULL value unless otherwise indicated in the documentation for a particular function or operator. Mathematical functions will return NULL on error ( for example; division by zero)
mysql> SELECT 1/0;
+——+
| 1/0 |
+——+
| NULL |
+——+
1 row in set (0.00 sec)
Examples
The following are examples of simple functions within a SELECT statement:
NOW()
The NOW function returns the current date/time.
VERSION()
The VERSION function returns the MySQL version currently being used on the database server host.
Numeric Functions
https://www.testingdocs.com/mysql-mathematical-functions/
String Functions
https://www.testingdocs.com/mysql-string-functions/
Temporal Functions
https://www.testingdocs.com/mysql-temporal-functions/
—
MySQL Tutorials
MySQL Tutorials on this website:
https://www.testingdocs.com/mysql-tutorials-for-beginners/