Example
Return the current version of the MySQL database:
SELECT VERSION();
Definition and Usage
The VERSION() function returns the current version of the MySQL database, as a string.
Syntax
VERSION()
Return the current version of the MySQL database:
SELECT VERSION();
The VERSION() function returns the current version of the MySQL database, as a string.
VERSION()
Return the current user name and host name for the MySQL connection:
SELECT USER();
The USER() function returns the current user name and host name for the MySQL connection.
USER()
Return the current user name and host name for the MySQL connection:
SELECT SYSTEM_USER();
The SYSTEM_USER() function returns the current user name and host name for the MySQL connection.
SYSTEM_USER()
Return the current user name and host name for the MySQL connection:
SELECT SESSION_USER();
The SESSION_USER() function returns the current user name and host name for the MySQL connection.
SESSION_USER()
Compare two expressions:
SELECT NULLIF(25, 25);
The NULLIF() function compares two expressions and returns NULL if they are equal. Otherwise, the first expression is returned.
NULLIF(expr1, expr2)
Return the AUTO_INCREMENT id of the last row that has been inserted in a table:
SELECT LAST_INSERT_ID();
The LAST_INSERT_ID() function returns the AUTO_INCREMENT id of the last row that has been inserted in a table.
LAST_INSERT_ID(expression)
Test whether an expression is NULL:
SELECT ISNULL(NULL);
The ISNULL() function returns 1 or 0 depending on whether an expression is NULL.
If expression is NULL, this function returns 1. Otherwise, it returns 0.
ISNULL(expression)
Return the specified value IF the expression is NULL, otherwise return the expression:
SELECT IFNULL(NULL, "Iampsp.com");
The IFNULL() function returns a specified value if the expression is NULL.
If the expression is NOT NULL, this function returns the expression.
IFNULL(expression, alt_value)
Return “YES” if the condition is TRUE, or “NO” if the condition is FALSE:
SELECT IF(500<1000, "YES", "NO");
The IF() function returns a value if a condition is TRUE, or another value if a condition is FALSE.
IF(condition, value_if_true, value_if_false)
Return the name of the current (default) database:
SELECT DATABASE();
The DATABASE() function returns the name of the current database.
If there is no current database, this function returns NULL or “”.
DATABASE()