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

What are the differences between xHTML and HTML tags?

All tags must be lowercase In XHTML, all tags must...

Detailed explanation of MySQL 30 military rules

1. Basic Specifications (1) InnoDB storage engine...

Getting Started Tutorial for Beginners⑧: Easily Create an Article Site

In my last post I talked about how to make a web p...

Detailed explanation of the process of using GPU in Docker

Table of contents Download tf-gpu Build your own ...

How to deal with time zone issues in Docker

background When I was using Docker these two days...

mysql charset=utf8 do you really understand what it means

1. Let's look at a table creation statement f...

Summarize the commonly used nth-child selectors

Preface In front-end programming, we often use th...

The meaning and calculation method of QPS and TPS of MySQL database

When doing DB benchmark testing, qps and tps are ...

The latest popular script Autojs source code sharing

Today I will share with you a source code contain...

Detailed explanation of Nginx static file service configuration and optimization

Root directory and index file The root directive ...

MySQL 8.0.21 installation tutorial under Windows system (illustration and text)

Installation suggestion : Try not to use .exe for...

MySQL uses frm files and ibd files to restore table data

Table of contents Introduction to frm files and i...

Web Design Tutorial (3): Design Steps and Thinking

<br />Previous tutorial: Web Design Tutorial...