MySQL---Commonly used functions

MySQL-commonly used functions

1. Mathematical functions

Function name Features
ABS(x) Returns the absolute value of x
SQRT(x) Returns the square root of a non-negative number x
CEIL(x),CEILIN(x) Returns the smallest integer value not less than x
FLOOR(x) Returns the largest integer value not greater than x
RAND() Return a random number from 0 to 1
RAND(x) Return a random number from 0 to 1, the same random number will be returned when the x value is the same
SIGN(x) The return parameter is the sign of -1, 0, 1, and the sign depends on the value of x being negative, zero or positive
PI() Returns the PI, the default display decimal place is 7 digits, mysql will use the full double-precision value internally
TRUNCATE(x,y) Return the value x to the y place value after the decimal point
ROUND(x) Returns the integer closest to x
ROUND(x,y) Keep the value of y digits after the x decimal point, but round off when truncating
POW (x, y), POWER (x, y) Returns the result of x to the y power
EXP(x) Returns the value of e (the base of the natural logarithm) raised to the x power
MOD (x, y) Returns the remainder after dividing x by y
LOG(x) Returns the base 2 logarithm of x
LOG10(x) Returns the base 10 logarithm of x
RADIANS(x) Convert angle to radians
DEGREES(x) Convert radians to angles
SIN (x) Returns the sine of x, where x is given in radians
ASIN(x) Returns the arc sine of x, that is, the sine is the value of x. If x is not in -1~1, return null
COS(x) Returns the cosine of x, where x is given in radians
ACOS(x) Returns the arc cosine of x, which is the value of x. If x is not in -1~1, return null
SO (x) Returns the arctangent value, that is, the value where the tangent is x
ATAN (x), ATAN (x, y) Returns the arc tangent of two variables x and y.
COT(x) Returns the cotangent of x
SIGN() Return the sign of the current result, if it is a negative number, return -1, if it is 0, return 0, if it is a positive number, return 1
FORMAT(x,y) Thousands will be automatically

fromat
[Note: Once your data is separated by thousands, it will become a string. The calculation will be very troublesome afterwards, so it is not recommended to use]

Two, string functions

Insert picture description here

Three, date function

Insert picture description here

Four, system information function

Function name Features
BENCHMARK(count,expr) Run the expression expr count times
CONNECTION_ID() Returns the connection ID of the current client
FOUND_ROWS() Returns the total number of rows retrieved by the last SELECT query
USER()或SYSTEM_USER() Return the current login user name
VERSION() Returns the version of the MySQL server

Five, statistical functions

Insert picture description here
count(): generally use count(1) instead of count(*), you can also put fields

Guess you like

Origin blog.csdn.net/qq_43288259/article/details/114117781