In MySQL Advanced Function Part-5 we will discuss about the LAST_INSERT_ID, LEAST, LOAD_FILE, MASTER_POS_WAIT, NULLIF, SESSION_USER, SYSTEM_USER, USER, VERSION
LEAST Function:- The LEAST Function is used for returning the least value of the given list of arguments.
Syntax:- LEAST(arg1, arg2,arg3,….)
SELECT LEAST(13, 15, 3, 9, 2);
SELECT LEAST(“kshtutor.com”, “srkpgroup.com”, “facebook.com”);
LOAD_FILE Function:- LOAD_FILE Function is used for reading files and returning the file content as a string.
Syntax:- LOAD_FILE(File path/file name)
Example:- SELECT * LOAD_FILE(“c:/filefolder/filename.txt”);
MASTER_POS_WAIT Function:- MASTER_POS_WAIT Function is also called MASTER_POS_WAIT() statement, But it is actually a function. It is used to ensure that the replica has read and executed events up to a given position in the source’s binary log.
From MySQL version 8.0.26 this function is deprecated and instead of this, we can use SOURCE_POS_WAIT() function.
LAST_INSERT_ID Function:- LAST_INSERT_ID Function is used to return the last AUTO_INCREMENT id. It is used after INSERT or UPDATE statement.
NULLIF Function:- NULLIF Function is used to compare two expressions. If both expressions are equal then it will return NULL otherwise It will return the first expression.
Syntax:- NULLIF(expr1, expr2)
SELECT NULLIF(“Red”, 13);
SESSION_USER Function, SYSTEM_USER Function, and USER Function:- SESSION_USER Function, SYSTEM_USER Function, and USER Function are used for returning the USERNAME and HOST name of the current MySQL connection.
VERSION Function:- The VERSION Function is used for returning the current version of MySQL.
Read more detail about functions in the MySQL manual.