This article introduces some common functions of MySQ functions.
IF(expr,v1,v2) Returns v1 when the expr expression is true, otherwise returns v2
##IFNULL(v1, v2) If v1 is NULL, return v2; if v1 is not NULL, return v1 CASE expr WHEN v1 THEN r1 [WHEN v2 THEN r2][......] [ELSE m ] ENDIf expr is equal to the value in v1.v2.., return r1, r2.. after THEN. Otherwise, return the value m## after THEN. #CASE WHEN v1 THEN r1 [WHEN v2 THEN r2][...] [ELSE m] END
When a value in v1, v2... is true, return the value after THEN , otherwise return the value after ELSE
##VERSION() Return the version of MySql
##CONNECTION_ID() Return the current Mysql Number of connections SHOW PROCESSLIST; SHOW FULL PROCESSLIST; Display running threads DATEBASE(),SCHEMA( ) Return the current database##USER(), CURRENT_USER(), SYSTEM_USER(), SESSION_USER() Return the current user name
CHARSET(str) Returns the character set of str
COLLATION(str) Returns the character arrangement of str
LAST_INSERT_ID() Returns the last id value generated by AUTO_INCREMENT. If data is inserted in batches, returns the first one in the batch
Encryption--MD5(str ) Return str MD5 encryption 32-digit hexadecimal
Encryption ENCODE (str, pwd_str) Use pwd_str as the password to encrypt str, a binary string with the same length as str
Decrypt DECODE('str', pwd_str) Use pwd_str as the password to decrypt str, which is the inverse function of the above ENCODE()
FORMAT(x,n) Format the number Convert N from the from_base base to the to_base base
##BENCHMARK(count, expr) Repeat expr for a total of count timesCONVERT(str USING charset) Convert str to the corresponding charset CAST(x AS type), CONVERT(x, type) Return to convert x to type Value of type
The above is the detailed content of Share examples of MySQ functions. For more information, please follow other related articles on the PHP Chinese website!