MySQL detailed summary of commonly used functions

MySQL detailed summary of commonly used functions

MySQL Common Functions

1. Numeric Functions

insert image description here

Additional: ceil(x) For example, if ceil(1.23) has a value of 2, it can be written as ceiling(x)

String functions

insert image description here

The dash is commonly used (to get the number of bytes)

insert image description here

Add: char_length character (query the last three digits of the name) For example: char_length(name)=3 can be written as:

select left(name,1) from c1;

3. Time function

insert image description here

Usage: select now();

4. System Function

insert image description here

To add a separator:

select concat_ws('#',name,tel,height) from xxb;
select (substr(Now(),1,4)-substr(age,1,4) as agefrom zxc;

Explanation of the following SQL statements: The first now() is used for comparison, interval 50 minute means pushing back 50 units, and -50 means pushing forward 50 units. year(now()) gets the year; month(now()) gets the month; day(now()) gets the day; nour(now()) gets the hour; minute(now()) gets the minute; second(now()) gets the second

select now(),date_add(now(),interval 50 minute);  

Get the day of the week:

select dayofweek(now()),dayname(now());

5. Aggregation Functions

Aggregate multiple data to calculate a single data value

insert image description here

usage:

select sum(height) from c1;

Get the number of records (number of rows), and filter out empty values: count() If there is one empty row in 14 rows, count() will be 13 rows. Count() can be accompanied by count(*) for more accuracy. Count(*) is generally used for statistics.

Calculate the difference between two dates in multiple units, such as: select timestampdiff (time unit, date time 1, date time 2) written as:

select timestampdiff(day,'2021-11-18','2021-11-22');

Please add a description of the image

Thank you to everyone who read my article carefully! ! ! If the following materials are useful, you can take them directly:

1. Complete project source code and environment required for self-study development or testing

2. All templates in testing work (test plan, test case, test report, etc.)

3. Classic software testing interview questions

4. Python/Java Automation Testing Practice.pdf

5. Jmeter/postman interface test full set of video acquisition

This is the end of this article on MySQL's detailed summary of commonly used functions. For more relevant MySQL commonly used functions, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Thoroughly understand MySQL stored procedures and functions
  • Analysis of the difference between MySQL stored functions and stored procedures
  • Introduction to commonly used functions in MYSQL database
  • MySQL batch inserts data through function stored procedures
  • MySQL stored functions detailed introduction
  • Detailed explanation of creating stored procedures and functions in mysql
  • Comprehensive summary of mysql functions
  • How to use MYSQL functions

<<:  Use ab tool to perform API stress test on the server

>>:  Example of converting JS one-dimensional array into three-dimensional array

Recommend

20 JS abbreviation skills to improve work efficiency

Table of contents When declaring multiple variabl...

Detailed explanation of daily_routine example code in Linux

First look at the example code: #/bin/bash cal da...

The difference between Input's size and maxlength attributes

I recently used the input size and maxlength attri...

Usage and principles of provide and inject in Vue3

Preface: When passing data between parent and chi...

Beginners understand MySQL deadlock problem from source code

After many difficult single-step debugging late a...

Solution to the problem of saving format in HTML TextArea

The format of textarea can be saved to the databas...

Detailed explanation of MySQL user rights management

Table of contents Preface: 1. Introduction to Use...

MySql 8.0.16-win64 Installation Tutorial

1. Unzip the downloaded file as shown below . 2. ...

Docker Nginx container production and deployment implementation method

Quick Start 1. Find the nginx image on Docker Hub...

js realizes the function of clicking to switch cards

This article example shares the specific code of ...

CSS to achieve dynamic secondary menu

Dynamically implement a simple secondary menu Whe...