1.MySQL functions 1. Mathematical functions PI() #Returns the value of pi (pi). The default number of decimal places is 6. FLOOR(x) returns the largest integer less than x (rounding off decimals) CEILING(x) rounds up ROUND (x, y) rounds the value of the operation to y decimal places. If y is a negative number, it rounds to y decimal places. RAND(x) returns a random number. If x is the same, the random number returned is the same. TURNCATE(x,y) returns x with y decimal places ABS(X) Returns the absolute value of x MOD(X, Y) returns the remainder after dividing X by Y, even for decimals. SQRT(x) Returns the square root of a non-negative number x. SIGN(X) returns the sign of the parameter. If the value of x is positive, 0, or negative, it returns 1, 0, or -1 respectively. POW(X,Y), POWER(X,Y), EXP(X) Power functions LOG(X), LOG10(X) Logarithmic operation RADIANS(X), DEGREES(X) functions for converting between degrees and radians SIN(X), ASIN(X) sine function, inverse sine function COS(X), ACOS(X) cosine and arccosine functions 2. Aggregate Functions AVG(x) #average COUNT(col) #Returns the number of non-controlled values in a column MIN(col) #Returns the minimum value of a column MAX(col) #Returns the maximum value of a column SUM(col) #Returns the sum of a column 3. String functions CONCAT(s1,s2,s3,...)#connect strings s1,s2,s3,... LTRIM(str) #Remove the space at the beginning of str RTRIM(str)#Remove the space at the end of str TRIM(str)#Remove spaces at both ends of STR substring(str, start interception position loc, interception length len) #loc=1: first position, 2 second position 4. Date functions YEAR(date) #Returns the year of date (1000-9999) MONTH(data)#Returns the month of date (1-12) DAY(data)#Return date (1-31) HOUR(time) MINUTE(time) SECOND(time) DATE(datetime) TIME(datetime) 5. Grouping Function as is a keyword for taking an alias, which can be omitted select mathematical function (field name) alias, field name from indicates group by field name #If you want to find the average score of each class #If you use a grouping function, the fields that are not in the group must be placed after group by The above is a detailed explanation and integration of MySQL database functions introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: How to build mysql master-slave server on centos7 (graphic tutorial)
>>: jQuery achieves large-screen scrolling playback effect
CSS naming conventions (rules) Commonly used CSS ...
Preface add_header is a directive defined in the ...
Table of contents Two ways to solve the problem o...
The webpage displays 403 Forbidden Nginx (yum ins...
WeChat Mini Program - QR Code Generator Download:...
Table of contents aforementioned VARCHAR Type VAR...
1. InnoDB locking mechanism The InnoDB storage en...
Table of contents 1. After downloading, unzip it ...
Table of contents Presentation Layer Business Lay...
Table of contents Preface Step 1: Setup and front...
Table of contents Preface Implementation ideas Im...
Table of contents 1. Forgot the root password and...
Insert image tag <IMG> The colorful web page...
Effective solution for Ubuntu in virtual machine ...
Table of contents 1. Parent component passes valu...