MySQL VERSION Function

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()

Continue reading MySQL VERSION Function

MySQL USER Function

Example

Return the current user name and host name for the MySQL connection:

SELECT USER();

Definition and Usage

The USER() function returns the current user name and host name for the MySQL connection.

Syntax

USER()

Continue reading MySQL USER Function

MySQL SYSTEM_USER Function

Example

Return the current user name and host name for the MySQL connection:

SELECT SYSTEM_USER();

Definition and Usage

The SYSTEM_USER() function returns the current user name and host name for the MySQL connection.

 

Syntax

SYSTEM_USER()

Continue reading MySQL SYSTEM_USER Function

MySQL SESSION_USER Function

Example

Return the current user name and host name for the MySQL connection:

SELECT SESSION_USER();

Definition and Usage

The SESSION_USER() function returns the current user name and host name for the MySQL connection.

 

Syntax

SESSION_USER()

Continue reading MySQL SESSION_USER Function

MySQL NULLIF Function

Example

Compare two expressions:

SELECT NULLIF(25, 25);

Definition and Usage

The NULLIF() function compares two expressions and returns NULL if they are equal. Otherwise, the first expression is returned.

Syntax

NULLIF(expr1, expr2)

Continue reading MySQL NULLIF Function

MySQL LAST_INSERT_ID Function

Example

Return the AUTO_INCREMENT id of the last row that has been inserted in a table:

SELECT LAST_INSERT_ID();

Definition and Usage

The LAST_INSERT_ID() function returns the AUTO_INCREMENT id of the last row that has been inserted in a table.

Syntax

LAST_INSERT_ID(expression)

Continue reading MySQL LAST_INSERT_ID Function

MySQL ISNULL Function

Example

Test whether an expression is NULL:

SELECT ISNULL(NULL);

Definition and Usage

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.

Syntax

ISNULL(expression)

Continue reading MySQL ISNULL Function

MySQL IFNULL Function

Example

Return the specified value IF the expression is NULL, otherwise return the expression:

SELECT IFNULL(NULL, "Iampsp.com");

Definition and Usage

The IFNULL() function returns a specified value if the expression is NULL.

If the expression is NOT NULL, this function returns the expression.

Syntax

IFNULL(expression, alt_value)

Continue reading MySQL IFNULL Function

MySQL IF Function

Example

Return “YES” if the condition is TRUE, or “NO” if the condition is FALSE:

SELECT IF(500<1000, "YES", "NO");

Definition and Usage

The IF() function returns a value if a condition is TRUE, or another value if a condition is FALSE.

Syntax

IF(condition, value_if_true, value_if_false)

Continue reading MySQL IF Function

MySQL DATABASE Function

Example

Return the name of the current (default) database:

SELECT DATABASE();

Definition and Usage

The DATABASE() function returns the name of the current database.

If there is no current database, this function returns NULL or “”.

Syntax

DATABASE()

Continue reading MySQL DATABASE Function