This article mainly shares with you the commonly used built-in functions in MySQL, including aggregate functions, mathematical functions, string functions, etc. I hope it can help you.
COUNT()
function: for any parameter except (*
), Returns the number of rows in the selected collection that are not null
values. For the parameter (*
), returns the number of all rows in the collection, including rows with null
values. . count(*)
without WHERE
is internally optimized by mysql and can return record parameters faster
SUN( )
Function: Find the sum of the values of a certain field in the table
AVG()
Function: Find the value of a certain field in the table The average value
MAX()
Function: Find the maximum value of a field in the table
MIN()
Function: Find the minimum value of a field in the table
ABS()
Function: Find the absolute value of a field in the table
FLOOR()
Function: Returns the largest integer less than or equal to parameter x
RAND()
Function: Returns a random number between 0~1
TRUNCATE(x,y)
Function: Returns the value of x retained to y digits after the decimal point
SQRT(x)
Function : Find the square root of parameter x
UPPER(s)
andUCASE(s)
Function: Convert all letters in string s to uppercase letters
LEFT(s,n)
Function: Return The first n characters of string x
##SUBSTRING(s,n,len)Function: Starting from the nth position of s, get the string
CURDATE() and
CURRENT_DATE() Function: used to get the current date
CURTIME() and
CURRENT_TIME() Function: used to get the current time
NOW() and
CURRENT_TIMESTAMP() Functions: Get the current date and time
IF(expr,v1,v2)Function: Indicates that if the expression expr is true, v1 will be executed, otherwise v2 will be executed. (Similar to Sanmu Budget)
IFNULL(expr,v2)Function: Indicates that if expr is not empty, return the value of the expression, otherwise return v2
VERSION()Function: Get the version number information of the system
PHP implementation does not use built-in functions to implement the string conversion method
Detailed explanation on the usage of JavaScript built-in function console
php Basic usage of built-in functions
The above is the detailed content of Commonly used built-in functions in mysql. For more information, please follow other related articles on the PHP Chinese website!