Software Testing - MySQL (VI: Database Functions)

Software Testing - MySQL (VI: Database Functions)

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:
  • PHP database connection tool class based on MySQLI function encapsulation [definition and usage]
  • Tutorial on creating a MySQL database with the help of PHP's mysql_query() function
  • Mysql database uses concat function to execute SQL injection query
  • Use the session_set_save_handler() function in PHP to save the session to the MySQL database instance
  • How to open, close, and view function functions of MySQL database
  • Introduction to mysql import and export database, functions and stored procedures
  • mysql query database stored procedures and functions statement
  • PHP access MYSQL database encapsulation class (with function description)
  • Common MYSQL functions in PHP (essential for operating databases under PHP)
  • MySQL database library

<<:  How to build mysql master-slave server on centos7 (graphic tutorial)

>>:  jQuery achieves large-screen scrolling playback effect

Recommend

CSS naming conventions (rules) worth collecting Commonly used CSS naming rules

CSS naming conventions (rules) Commonly used CSS ...

Complete steps to solve 403 forbidden in Nginx

The webpage displays 403 Forbidden Nginx (yum ins...

WeChat Mini Program QR Code Generation Tool weapp-qrcode Detailed Explanation

WeChat Mini Program - QR Code Generator Download:...

Difference between varchar and char types in MySQL

Table of contents aforementioned VARCHAR Type VAR...

Detailed Example of MySQL InnoDB Locking Mechanism

1. InnoDB locking mechanism The InnoDB storage en...

Detailed tutorial on installing MySQL 8.0.19 in zip version on win10

Table of contents 1. After downloading, unzip it ...

React implements import and export of Excel files

Table of contents Presentation Layer Business Lay...

How to implement real-time polygon refraction with threejs

Table of contents Preface Step 1: Setup and front...

How to reset MySQL root password

Table of contents 1. Forgot the root password and...

HTML web page image tag

Insert image tag <IMG> The colorful web page...

Solution to Ubuntu cannot connect to the network

Effective solution for Ubuntu in virtual machine ...